moc en QT suele compilar mi archivo de cabecera C ++. dice que es demasiado diferente
Pregunta
wtf bien esto es lo que me dice moc cuando intento MOC uno de mis archivos de cabecera. estoy haciendo esto a través de Qt 4.5.3 símbolo del sistema y dice esto:
C:\Documents and Settings\The Fuzz\Desktop\GUI2>moc App_interface.h
/****************************************************************************
** Meta object code from reading C++ file 'App_interface.h'
**
** Created: Mon Oct 12 16:58:11 2009
** by: The Qt Meta Object Compiler version 61 (Qt 4.5.3)
**
** WARNING! All changes made in this file will be lost!
*****************************************************************************/
#include "App_interface.h"
#if !defined(Q_MOC_OUTPUT_REVISION)
#error "The header file 'App_interface.h' doesn't include <QObject>."
#elif Q_MOC_OUTPUT_REVISION != 61
#error "This file was generated using the moc from 4.5.3. It"
#error "cannot be used with the include files from this version of Qt."
#error "(The moc has changed too much.)"
#endif
QT_BEGIN_MOC_NAMESPACE
static const uint qt_meta_data_App_interface[] = {
// content:
2, // revision
0, // classname
0, 0, // classinfo
0, 0, // methods
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
0 // eod
};
static const char qt_meta_stringdata_App_interface[] = {
"App_interface\0"
};
const QMetaObject App_interface::staticMetaObject = {
{ &QWidget::staticMetaObject, qt_meta_stringdata_App_interface,
qt_meta_data_App_interface, 0 }
};
const QMetaObject *App_interface::metaObject() const
{
return &staticMetaObject;
}
void *App_interface::qt_metacast(const char *_clname)
{
if (!_clname) return 0;
if (!strcmp(_clname, qt_meta_stringdata_App_interface))
return static_cast<void*>(const_cast< App_interface*>(this));
return QWidget::qt_metacast(_clname);
}
int App_interface::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QWidget::qt_metacall(_c, _id, _a);
if (_id < 0)
return _id;
return _id;
}
QT_END_MOC_NAMESPACE
C:\Documents and Settings\The Fuzz\Desktop\GUI2>
alguna idea ??? im tratando de utilizar la macro Q_OBJECT.
Solución
moc
convierte su cabecera de entrada en un archivo generado, que se imprime en su salida. Debe enviar su salida a un archivo, con un comando como:
moc App_interface.h > App_interface.h_moc
a continuación, incluir eso.
Si está utilizando QMake, creo que este proceso está automatizado.
Otros consejos
Esto también puede ayudar: hay que heredar de otras clases antes QObject: http://doc.trolltech.com/4.1/moc.html#multiple-inheritance-requires-qobject-to-be-first .
De acuerdo con la respuesta anterior, es mucho mejor usar qmake.
Me gustaría recomendar encarecidamente el uso de un IDE Qt Creator , en lugar de construir a partir la línea de comandos.