@ -1,4 +1,4 @@
.TH moc 1 "24 June 2001" "Trolltech AS" \" -*- nroff -*-
.TH tq moc 1 "24 June 2001" "Trolltech AS" \" -*- nroff -*-
. \"
. \"
. \" $Id: qt/moc.1 3.3.8 edited Jan 11 14:38 $
. \" $Id: qt/moc.1 3.3.8 edited Jan 11 14:38 $
. \"
. \"
@ -9,28 +9,28 @@
. \"
. \"
.nh
.nh
.SH NAME
.SH NAME
moc \- generate Qt meta object support code
tq moc \- generate T Qt meta object support code
.SH SYNOPSIS
.SH SYNOPSIS
.B moc
.B tq moc
[-o file] [-i] [-f] [-k] [-ldbg] [-nw] [-p path] [-q path] [-v] file
[-o file] [-i] [-f] [-k] [-ldbg] [-nw] [-p path] [-q path] [-v] file
.SH DESCRIPTION
.SH DESCRIPTION
This page documents the
This page documents the
.B Meta Object Compiler
.B Meta Object Compiler
for the Qt GUI application framework. The
for the T Qt GUI application framework. The
.B moc
.B tq moc
reads one or more C++ class declarations from a C++ header or source
reads one or more C++ class declarations from a C++ header or source
file and generates one C++ source file containing meta object
file and generates one C++ source file containing meta object
information for the classes. The C++ source file generated by the
information for the classes. The C++ source file generated by the
.B moc
.B tq moc
must be compiled and linked with the implementation of the class (or it
must be compiled and linked with the implementation of the class (or it
can be #included into the class's source file).
can be #included into the class's source file).
.PP
.PP
If you use
If you use
.B qmake
.B t qmake
to create your Makefiles, build rules will be included that call the
to create your Makefiles, build rules will be included that call the
.B moc
.B tq moc
when required, so you will not need to use the
when required, so you will not need to use the
.B moc
.B tq moc
directly.
directly.
.PP
.PP
In brief, the meta object system is a structure used by Qt (see
In brief, the meta object system is a structure used by Qt (see
@ -61,7 +61,7 @@ standard naming conventions.
.I "-i"
.I "-i"
Do not generate an #include statement in the output. This may be used
Do not generate an #include statement in the output. This may be used
to run
to run
.B moc
.B tq moc
on a C++ file containing one or more class declarations. You should then
on a C++ file containing one or more class declarations. You should then
#include the meta object code in the .cpp file (see USAGE below). If both
#include the meta object code in the .cpp file (see USAGE below). If both
.I -f
.I -f
@ -77,51 +77,51 @@ Write a flood of lex debug information to stdout.
.TP
.TP
.I "-p path"
.I "-p path"
Makes
Makes
.B moc
.B tq moc
prepend
prepend
.IR path /
.IR path /
to the file name in the generated #include statement (if one is generated).
to the file name in the generated #include statement (if one is generated).
.TP
.TP
.I "-q path"
.I "-q path"
Makes
Makes
.B moc
.B tq moc
prepend
prepend
.IR path /
.IR path /
to the file name of qt #include files in the generated code.
to the file name of qt #include files in the generated code.
.TP
.TP
.I "-v"
.I "-v"
Displays the version of
Displays the version of
.B moc
.B tq moc
and Qt.
and T Qt.
.PP
.PP
You can explicitly tell the
You can explicitly tell the
.B moc
.B tq moc
not to parse parts of a header
not to parse parts of a header
file. It recognizes any C++ comment (//) that contains the substrings
file. It recognizes any C++ comment (//) that contains the substrings
MOC_SKIP_BEGIN or MOC_SKIP_END. They work as you would expect and you
MOC_SKIP_BEGIN or MOC_SKIP_END. They work as you would expect and you
can have several levels of them. The net result as seen by the
can have several levels of them. The net result as seen by the
.B moc
.B tq moc
is as if you had removed all lines between a MOC_SKIP_BEGIN and a
is as if you had removed all lines between a MOC_SKIP_BEGIN and a
MOC_SKIP_END
MOC_SKIP_END
.SH USAGE
.SH USAGE
.B moc
.B tq moc
is almost always invoked by
is almost always invoked by
.BR make (1),
.BR make (1),
not by hand.
not by hand.
.PP
.PP
.B moc
.B tq moc
is typically used with an input file containing class declarations
is typically used with an input file containing class declarations
like this:
like this:
.PP
.PP
.in +4
.in +4
.nf
.nf
class YourClass : public QObject {
class YourClass : public T QObject {
TQ_OBJECT
TQ_OBJECT
TQ_PROPERTY( ... )
TQ_PROPERTY( ... )
TQ_CLASSINFO( ... )
TQ_CLASSINFO( ... )
public:
public:
YourClass( QObject * parent=0, const char * name=0 );
YourClass( T QObject * parent=0, const char * name=0 );
~YourClass();
~YourClass();
signals:
signals:
@ -137,7 +137,7 @@ Here is a useful makefile rule if you only use GNU make:
.in +4
.in +4
.nf
.nf
m%.cpp: %.h
m%.cpp: %.h
moc $< -o $@
tq moc $< -o $@
.fi
.fi
.in -4
.in -4
.PP
.PP
@ -147,7 +147,7 @@ following form:
.in +4
.in +4
.nf
.nf
mNAME.cpp: NAME.h
mNAME.cpp: NAME.h
moc $< -o $@
tq moc $< -o $@
.fi
.fi
.in -4
.in -4
.PP
.PP
@ -158,7 +158,7 @@ to your SOURCES (substitute your favorite name) variable and
to your OBJECTS variable.
to your OBJECTS variable.
.PP
.PP
(While we prefer to name our C++ source files .cpp, the
(While we prefer to name our C++ source files .cpp, the
.B moc
.B tq moc
doesn't know that, so you can use .C, .cc, .CC, .cxx or even .c++ if
doesn't know that, so you can use .C, .cc, .CC, .cxx or even .c++ if
you prefer.)
you prefer.)
.PP
.PP
@ -170,14 +170,14 @@ a makefile rule like this:
NAME.o: mNAME.cpp
NAME.o: mNAME.cpp
mNAME.cpp: NAME.cpp
mNAME.cpp: NAME.cpp
moc -i $< -o $@
tq moc -i $< -o $@
.fi
.fi
.in -4
.in -4
.PP
.PP
This guarantees that
This guarantees that
.BR make (1)
.BR make (1)
will run the
will run the
.B moc
.B tq moc
before it compiles
before it compiles
.IR NAME.cpp .
.IR NAME.cpp .
You can then put
You can then put
@ -192,29 +192,29 @@ where all the classes declared in that file are fully known.
Sometimes you may get linkage errors, saying that
Sometimes you may get linkage errors, saying that
YourClass::className() is undefined or that YourClass lacks a vtbl.
YourClass::className() is undefined or that YourClass lacks a vtbl.
Those errors happen most often when you forget to compile the
Those errors happen most often when you forget to compile the
moc-generated C++ code or include that object file in the link
tq moc-generated C++ code or include that object file in the link
command.
command.
.PP
.PP
The
The
.B moc
.B tq moc
will warn you about a number of dangerous or illegal constructs.
will warn you about a number of dangerous or illegal constructs.
.SH BUGS
.SH BUGS
The
The
.B moc
.B tq moc
does not expand #include or #define, it simply skips any preprocessor
does not expand #include or #define, it simply skips any preprocessor
directives it encounters. This is regrettable, but is normally not a
directives it encounters. This is regrettable, but is normally not a
problem in practice.
problem in practice.
The
The
.B moc
.B tq moc
does not handle all of C++. The main problem is that class templates
does not handle all of C++. The main problem is that class templates
cannot have signals or slots. This is an important bug. Here is an
cannot have signals or slots. This is an important bug. Here is an
example:
example:
.PP
.PP
.in +4
.in +4
.nf
.nf
class SomeTemplate<int> : public QFrame {
class SomeTemplate<int> : public T QFrame {
TQ_OBJECT
TQ_OBJECT
....
....
signals:
signals:
@ -226,35 +226,35 @@ signals:
Less importantly, the following constructs are illegal. All of them
Less importantly, the following constructs are illegal. All of them
have have alternatives which we think are usually better, so removing
have have alternatives which we think are usually better, so removing
these limitations is not a high priority for us.
these limitations is not a high priority for us.
.SS "Multiple inheritance requires QObject to be first."
.SS "Multiple inheritance requires T QObject to be first."
If you are using multiple inheritance,
If you are using multiple inheritance,
.B moc
.B tq moc
assumes that the
assumes that the
.B first
.B first
inherited class is a subclass of QObject. Also, be sure that
inherited class is a subclass of T QObject. Also, be sure that
.B only
.B only
the first inherited class is a QObject.
the first inherited class is a T QObject.
.PP
.PP
.in +4
.in +4
.nf
.nf
class SomeClass : public QObject, public OtherClass {
class SomeClass : public T QObject, public OtherClass {
...
...
};
};
.fi
.fi
.in -4
.in -4
.PP
.PP
This bug is almost impossible to fix; since the
This bug is almost impossible to fix; since the
.B moc
.B tq moc
does not expand
does not expand
#include or #define, it cannot find out which one of the base classes is a
#include or #define, it cannot find out which one of the base classes is a
QObject.
T QObject.
.SS "Function pointers cannot be arguments to signals or slots."
.SS "Function pointers cannot be arguments to signals or slots."
In most cases where you would consider that, we think inheritance is a
In most cases where you would consider that, we think inheritance is a
better alternative. Here is an example of illegal syntax:
better alternative. Here is an example of illegal syntax:
.PP
.PP
.in +4
.in +4
.nf
.nf
class SomeClass : public QObject {
class SomeClass : public T QObject {
TQ_OBJECT
TQ_OBJECT
...
...
public slots:
public slots:
@ -270,7 +270,7 @@ You can work around this restriction like this:
.nf
.nf
typedef void (*ApplyFunctionType)( List *, void * );
typedef void (*ApplyFunctionType)( List *, void * );
class SomeClass : public QObject {
class SomeClass : public T QObject {
TQ_OBJECT
TQ_OBJECT
...
...
public slots:
public slots:
@ -295,7 +295,7 @@ sections instead. Here is an example of the illegal syntax:
.PP
.PP
.in +4
.in +4
.nf
.nf
class SomeClass : public QObject {
class SomeClass : public T QObject {
TQ_OBJECT
TQ_OBJECT
...
...
signals:
signals:
@ -311,16 +311,16 @@ example:
.PP
.PP
.in +4
.in +4
.nf
.nf
class Whatever : public QButtonGroup {
class Whatever : public T QButtonGroup {
...
...
public slots:
public slots:
QButtonGroup::buttonPressed; // illegal
T QButtonGroup::buttonPressed; // illegal
...
...
};
};
.fi
.fi
.in -4
.in -4
.PP
.PP
The QButtonGroup::buttonPressed() slot is protected.
The T QButtonGroup::buttonPressed() slot is protected.
.PP
.PP
C++ quiz: What happens if you try to upgrade a protected member
C++ quiz: What happens if you try to upgrade a protected member
function which is overloaded?
function which is overloaded?
@ -332,7 +332,7 @@ function which is overloaded?
.SS "Type macros cannot be used for signal and slot arguments"
.SS "Type macros cannot be used for signal and slot arguments"
Since the
Since the
.B moc
.B tq moc
does not expand #define, type macros that take an argument
does not expand #define, type macros that take an argument
will not work in signals and slots. Here is an illegal example:
will not work in signals and slots. Here is an illegal example:
.PP
.PP
@ -343,7 +343,7 @@ will not work in signals and slots. Here is an illegal example:
#else
#else
#define SIGNEDNESS(a) a
#define SIGNEDNESS(a) a
#endif
#endif
class Whatever : public QObject {
class Whatever : public T QObject {
...
...
signals:
signals:
void someSignal( SIGNEDNESS(int) ); // illegal
void someSignal( SIGNEDNESS(int) ); // illegal
@ -388,11 +388,11 @@ sections, where they belong. Here is an example of the illegal syntax:
.PP
.PP
.in +4
.in +4
.nf
.nf
class SomeClass : public QObject {
class SomeClass : public T QObject {
TQ_OBJECT
TQ_OBJECT
public slots:
public slots:
SomeClass( QObject *parent, const char *name )
SomeClass( T QObject *parent, const char *name )
: QObject( parent, name ) {} // illegal
: T QObject( parent, name ) {} // illegal
...
...
};
};
.fi
.fi
@ -402,14 +402,14 @@ public slots:
Declaring the first property within or after the public section that
Declaring the first property within or after the public section that
contains the type definition and the respective get and set functions
contains the type definition and the respective get and set functions
does not work as expected. The
does not work as expected. The
.B moc
.B tq moc
will complain that it can neither
will complain that it can neither
find the functions nor resolve the type. Here is an example of the
find the functions nor resolve the type. Here is an example of the
illegal syntax:
illegal syntax:
.PP
.PP
.in +4
.in +4
.nf
.nf
class SomeClass : public QObject {
class SomeClass : public T QObject {
TQ_OBJECT
TQ_OBJECT
public:
public:
...
...
@ -429,7 +429,7 @@ beginning of the class declaration, right after TQ_OBJECT:
.PP
.PP
.in +4
.in +4
.nf
.nf
class SomeClass : public QObject {
class SomeClass : public T QObject {
TQ_OBJECT
TQ_OBJECT
TQ_PROPERTY( Priority priority READ priority WRITE setPriority )
TQ_PROPERTY( Priority priority READ priority WRITE setPriority )
TQ_ENUMS( Priority )
TQ_ENUMS( Priority )