blob: 60cf2a4eb818a5d23f67d7236b5eed3261c2c467 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
/*!
\page qmlmodules.html
\target qmlmodules
\title Modules of Components
A \bold module is a collection of \l Components.
To use a module, include the following statement at the begining
of your QML:
\code
import "path"
\endcode
This allows all components defined in the directory \c path to be used in
the component where this statement appears.
Currently, \c path may only be a directory relative to the directory containing
the component issuing the import.
The import statement cannot be used by remote content.
*/
/*
Ideas for full module support....
See QT-558.
* Modularity within applications
This is the currently-supported mechanism.
By using the "import" statement, a subdirectory of types can be added to the
empty namespace. Alternatively, a type in a subdirectory can be referenced
explicitly.
So, given these files:
./SubModule1/Type1.qml
./SubModule2/Type1.qml
This is valid QML:
import "SubModule1"
Type1 { ... }
SubModule2.Type1 { ... }
* System-installed modules (dependencies)
To use system-installed modules, the dependency must be explicitly stated
using the "require" statement. Types in required modules must still be
explicitly qualified. Dependencies cannot be added to the empty namespace.
QMLPATH=/opt/Nokia/qml:/usr/share/lib/qml
/opt/Nokia/qml/Module1/Type1.qml
/usr/share/lib/qml/Module1/Type1.qml
require "Module1"
Module1.Type1 { ... }
* Grouping of components within application modules
Sub-sub directories allow further grouping of types.
./SubModule1/Group1/*.qml
./SubModule1/Group2/*.qml
SubModule1.Group1.Type1 { ... }
SubModule1.Group1.Type2 { ... }
SubModule1.Group2.Type1 { ... }
SubModule1.Group2.Type2 { ... }
import "SubModule1/Group1"
Type1 { ... }
import "SubModule1"
Group1.Type1 { ... }
* Grouping of components within system-installed modules
System-installed types may also be grouped into types. The hierarchy is a
global namespace, so such grouping is recommended to reduce clashes.
/opt/Nokia/qml/Module1/Group1/*.qml
/opt/Nokia/qml/Module1/Group2/*.qml
require "Module1"
Module1.Group1.Type1 { ... }
Module1.Group1.Type2 { ... }
Module1.Group2.Type1 { ... }
Module1.Group2.Type2 { ... }
require "Module1/Group1"
Group1.Type1 { ... }
// Alternative syntax
/opt/qml/com/nokia/qml/Module1/Group1/*.qml
require "com.nokia.qml.Module1.Group1"
Group1.Type1 { ... }
* Private sub-components
Directories begining with _ cannot be referenced except by types in the
directory immediately containing it.
/opt/Nokia/qml/Module1/_private/Type1.qml
./SubModule1/_private/Type1.qml
SubModule1._private.Type1 { ... } // Not allowed
import "SubModule1._private" // Not allowed
require "SubModule1._private" // Not allowed
require "SubModule1"
Module1._private.Type1 { ... } // Not allowed
import "_private" // allowed
Type1 { ... }
*/
|