OSDN Git Service

5734d88057a2646e57a5c6216f27c3179c7af52f
[kde/Katie.git] / src / tools / moc / moc.1
1 .\" Automatically generated by Pod::Man 4.10 (Pod::Simple 3.35)
2 .\"
3 .\" Standard preamble:
4 .\" ========================================================================
5 .de Sp \" Vertical space (when we can't use .PP)
6 .if t .sp .5v
7 .if n .sp
8 ..
9 .de Vb \" Begin verbatim text
10 .ft CW
11 .nf
12 .ne \\$1
13 ..
14 .de Ve \" End verbatim text
15 .ft R
16 .fi
17 ..
18 .\" Set up some character translations and predefined strings.  \*(-- will
19 .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
20 .\" double quote, and \*(R" will give a right double quote.  \*(C+ will
21 .\" give a nicer C++.  Capital omega is used to do unbreakable dashes and
22 .\" therefore won't be available.  \*(C` and \*(C' expand to `' in nroff,
23 .\" nothing in troff, for use with C<>.
24 .tr \(*W-
25 .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
26 .ie n \{\
27 .    ds -- \(*W-
28 .    ds PI pi
29 .    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
30 .    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
31 .    ds L" ""
32 .    ds R" ""
33 .    ds C` ""
34 .    ds C' ""
35 'br\}
36 .el\{\
37 .    ds -- \|\(em\|
38 .    ds PI \(*p
39 .    ds L" ``
40 .    ds R" ''
41 .    ds C`
42 .    ds C'
43 'br\}
44 .\"
45 .\" Escape single quotes in literal strings from groff's Unicode transform.
46 .ie \n(.g .ds Aq \(aq
47 .el       .ds Aq '
48 .\"
49 .\" If the F register is >0, we'll generate index entries on stderr for
50 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
51 .\" entries marked with X<> in POD.  Of course, you'll have to process the
52 .\" output yourself in some meaningful fashion.
53 .\"
54 .\" Avoid warning from groff about undefined register 'F'.
55 .de IX
56 ..
57 .nr rF 0
58 .if \n(.g .if rF .nr rF 1
59 .if (\n(rF:(\n(.g==0)) \{\
60 .    if \nF \{\
61 .        de IX
62 .        tm Index:\\$1\t\\n%\t"\\$2"
63 ..
64 .        if !\nF==2 \{\
65 .            nr % 0
66 .            nr F 2
67 .        \}
68 .    \}
69 .\}
70 .rr rF
71 .\" ========================================================================
72 .\"
73 .IX Title "MOC 1"
74 .TH MOC 1 "2021-07-14" "Katie 4.11.0" "Katie Manual"
75 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
76 .\" way too many mistakes in technical documents.
77 .if n .ad l
78 .nh
79 .SH "NAME"
80 moc \- Katie meta object support code generator
81 .SH "SYNOPSIS"
82 .IX Header "SYNOPSIS"
83 moc [options] <source\-file|header\-file> [<source\-file|header\-file>] ...
84 .SH "DESCRIPTION"
85 .IX Header "DESCRIPTION"
86 moc reads one or more \*(C+ class declarations from a \*(C+ header or source file
87 and generates one \*(C+ source file containing meta object information for the
88 classes. The \*(C+ source file generated by the moc must be compiled and linked
89 with the implementation of the class (or it can be #included into the class's
90 source file).
91 .SH "OPTIONS"
92 .IX Header "OPTIONS"
93 .Vb 2
94 \&    \-o<file>
95 \&        Write output to file rather than stdout.
96 \&
97 \&    \-I<dir>
98 \&        Add dir to the include path for header files.
99 \&
100 \&    \-E
101 \&        Preprocess only; do not generate meta object code.
102 \&
103 \&    \-D<macro>[=<def>]
104 \&        define macro, with optional definition.
105 \&
106 \&    \-U<macro>
107 \&        Undefine macro.
108 \&
109 \&    \-i
110 \&        Do not generate an #include statement.
111 \&
112 \&    \-p<path>
113 \&        Path prefix for included file.
114 \&
115 \&    \-f[<file>]
116 \&        Force #include, optional file name.
117 \&
118 \&    \-nn
119 \&        Do not display notes.
120 \&
121 \&    \-nw
122 \&        Do not display warnings.
123 \&
124 \&    @<file>
125 \&        Read additional options from file.
126 \&
127 \&    \-v
128 \&        Display version of moc.
129 .Ve
130 .SH "EXIT STATUS"
131 .IX Header "EXIT STATUS"
132 moc returns 0 on success and other on unexcepted failure.
133 .SH "BUGS"
134 .IX Header "BUGS"
135 The moc does not expand #include or #define, it simply skips any
136 preprocessor directives it encounters. This is regrettable, but is normally
137 not a problem in practice.
138 .PP
139 The moc does not handle all of \*(C+. The main problem is that class
140 templates cannot have signals or slots. This is an important bug. Here is
141 an example:
142 .PP
143 .Vb 6
144 \&    class SomeTemplate<int> : public QFrame {
145 \&        Q_OBJECT
146 \&        ....
147 \&    signals:
148 \&        void bugInMocDetected( int );
149 \&    };
150 .Ve
151 .PP
152 Less importantly, the following constructs are illegal. All of them have
153 have alternatives which we think are usually better, so removing these
154 limitations is not a high priority for us.
155 .SS "Multiple inheritance requires QObject to be first."
156 .IX Subsection "Multiple inheritance requires QObject to be first."
157 .Vb 3
158 \&    If you are using multiple inheritance, moc assumes that the first inherited
159 \&    class is a subclass of QObject. Also, be sure that only the first inherited
160 \&    class is a QObject.
161 \&
162 \&        class SomeClass : public QObject, public OtherClass {
163 \&            ...
164 \&        };
165 \&
166 \&    This bug is almost impossible to fix; since the moc does not expand #include
167 \&    or #define, it cannot find out which one of the base classes is a QObject.
168 .Ve
169 .SS "Function pointers cannot be arguments to signals or slots."
170 .IX Subsection "Function pointers cannot be arguments to signals or slots."
171 .Vb 2
172 \&    In most cases where you would consider that, we think inheritance is a
173 \&    better alternative. Here is an example of illegal syntax:
174 \&
175 \&        class SomeClass : public QObject {
176 \&            Q_OBJECT
177 \&            ...
178 \&        public slots:
179 \&            // illegal
180 \&            void apply( void (*apply)(List *, void *), void * );
181 \&        };
182 \&
183 \&    You can work around this restriction like this:
184 \&
185 \&        typedef void (*ApplyFunctionType)( List *, void * );
186 \&
187 \&        class SomeClass : public QObject {
188 \&            Q_OBJECT
189 \&            ...
190 \&        public slots:
191 \&            void apply( ApplyFunctionType, char * );
192 \&        };
193 \&
194 \&    It  may  sometimes  be  even  better  to  replace  the function pointer with
195 \&    inheritance and virtual functions, signals or slots.
196 .Ve
197 .SS "Friend declarations cannot be placed in signals or slots sections"
198 .IX Subsection "Friend declarations cannot be placed in signals or slots sections"
199 .Vb 3
200 \&    Sometimes it will work, but in general, friend declarations cannot be placed
201 \&    in signals or slots sections. Put them in the good old private, protected
202 \&    or public sections instead. Here is an example of the illegal syntax:
203 \&
204 \&        class SomeClass : public QObject {
205 \&            Q_OBJECT
206 \&            ...
207 \&        signals:
208 \&            friend class ClassTemplate<char>; // illegal
209 \&        };
210 .Ve
211 .SS "Signals and slots cannot be upgraded"
212 .IX Subsection "Signals and slots cannot be upgraded"
213 .Vb 2
214 \&    The C++ feature of upgrading an inherited member function to public status
215 \&    is not extended to cover signals and slots. Here is an illegal example:
216 \&
217 \&        class Whatever : public QButtonGroup {
218 \&            ...
219 \&        public slots:
220 \&            QButtonGroup::buttonPressed; // illegal
221 \&            ...
222 \&        };
223 \&
224 \&    The QButtonGroup::buttonPressed() slot is protected.
225 \&
226 \&    C++ quiz: What happens if you try to upgrade a protected member function
227 \&    which is overloaded?
228 \&
229 \&        \- All the functions are upgraded.
230 \&
231 \&        \- That is not legal C++.
232 .Ve
233 .SS "Type macros cannot be used for signal and slot arguments"
234 .IX Subsection "Type macros cannot be used for signal and slot arguments"
235 .Vb 2
236 \&    Since the moc does not expand #define, type macros that take an argument
237 \&    will not work in signals and slots. Here is an illegal example:
238 \&
239 \&        #ifdef Q_OS_LINUX
240 \&        #define SIGNEDNESS(a) unsigned a
241 \&        #else
242 \&        #define SIGNEDNESS(a) a
243 \&        #endif
244 \&        class Whatever : public QObject {
245 \&            ...
246 \&        signals:
247 \&            void someSignal( SIGNEDNESS(int) ); // illegal
248 \&        };
249 \&
250 \&    A #define without arguments works.
251 .Ve
252 .SS "Nested  classes  cannot  be in the signals or slots sections nor have signals or slots"
253 .IX Subsection "Nested classes cannot be in the signals or slots sections nor have signals or slots"
254 .Vb 1
255 \&    Here\*(Aqs an example:
256 \&
257 \&        class A {
258 \&            Q_OBJECT
259 \&        public:
260 \&            class B {
261 \&            public slots: // illegal
262 \&                void b();
263 \&                ...
264 \&            };
265 \&        signals:
266 \&            class B {  // illegal
267 \&                void b();
268 \&            ...
269 \&            }:
270 \&        };
271 .Ve
272 .SS "Constructors cannot be used in signals or slots sections"
273 .IX Subsection "Constructors cannot be used in signals or slots sections"
274 .Vb 4
275 \&    It is a mystery to us why anyone would put a constructor on either the
276 \&    signals or slots sections. You can\*(Aqt, anyway (except that it happens to
277 \&    work in some cases). Put them in private, protected or public sections,
278 \&    where they belong. Here is an example of the illegal syntax:
279 \&
280 \&        class SomeClass : public QObject {
281 \&            Q_OBJECT
282 \&        public slots:
283 \&            SomeClass( QObject *parent, const char *name )
284 \&                : QObject( parent, name ) {} // illegal
285 \&            ...
286 \&        };
287 .Ve
288 .SS "Properties need to be declared before the public section that contains the respective get and set functions"
289 .IX Subsection "Properties need to be declared before the public section that contains the respective get and set functions"
290 .Vb 4
291 \&    Declaring the first property within or after the public section that
292 \&    contains the type definition and the respective get and set functions does
293 \&    not work as expected. The moc will complain that it can neither find the
294 \&    functions nor resolve the type. Here is an example of the illegal syntax:
295 \&
296 \&        class SomeClass : public QObject {
297 \&            Q_OBJECT
298 \&        public:
299 \&            ...
300 \&            // illegal
301 \&            Q_PROPERTY( Priority priority READ priority WRITE setPriority )
302 \&            Q_ENUMS( Priority )
303 \&            enum Priority { High, Low, VeryHigh, VeryLow };
304 \&            void setPriority( Priority );
305 \&            Priority priority() const;
306 \&            ...
307 \&        };
308 \&
309 \&    Work  around this limitation by declaring all properties at the beginning of
310 \&    the class declaration, right after Q_OBJECT:
311 \&
312 \&        class SomeClass : public QObject {
313 \&            Q_OBJECT
314 \&            Q_PROPERTY( Priority priority READ priority WRITE setPriority )
315 \&            Q_ENUMS( Priority )
316 \&        public:
317 \&            ...
318 \&            enum Priority { High, Low, VeryHigh, VeryLow };
319 \&            void setPriority( Priority );
320 \&            Priority priority() const;
321 \&            ...
322 \&        };
323 .Ve
324 .SH "AUTHORS"
325 .IX Header "AUTHORS"
326 The Qt Company Ltd.
327 .PP
328 Copyright (C) 2015 The Qt Company Ltd.
329 Copyright (C) 2016 Ivailo Monev
330 .PP
331 Licensed through \s-1GNU\s0 Lesser General Public License/GNU General Public License.