MOC in QT solito compilare il mio c ++ file di intestazione. dice la sua troppo diverso

StackOverflow https://stackoverflow.com/questions/1557579

  •  21-09-2019
  •  | 
  •  

Domanda

ok WTF questo è ciò che moc mi dice quando provo a moc uno dei miei file di intestazione. sto facendo questo attraverso Qt 4.5.3 prompt dei comandi e si dice questo:

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>

tutte le idee ??? im cercando di utilizzare il Macro Q_OBJECT.

È stato utile?

Soluzione

moc converte l'intestazione input in un file generato, che è stampato sulla sua uscita. Si dovrebbe inviare il suo output in un file, con un comando come:

moc App_interface.h > App_interface.h_moc

quindi includere questo.

Se stai usando QMake, credo che questo processo è automatizzato.

Altri suggerimenti

Questo può anche aiutare: è necessario ereditare da QObject prima di altre classi: http://doc.trolltech.com/4.1/moc.html#multiple-inheritance-requires-qobject-to-be-first .

Come per la precedente risposta, è molto meglio usare qmake.

Mi consiglia vivamente di utilizzare un IDE Qt Creator , piuttosto che costruire da la riga di comando.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top