Installiert habbe ich alles nach dem hier http://qtnode.net/wiki/Qt4_with_Visual_Studio
Hab jetzt mithilfe von make -project ein .pro-File erzeugt. Dann ein MSVC2005-Project mittels qmake -tp vc. Bekomme beim Builden wenn ich irgendwo das Makro Q_OBJECT drinnenhabe vfolgende Fehlermeldungen(die Klasse heißt MyLegoViewer:
main.obj : error LNK2001: Nicht aufgelöstes externes Symbol ""public: virtual struct QMetaObject const * __thiscall MyLegoViewer::metaObject(void)const " (?metaObject@MyLegoViewer@@UBEPBUQMetaObject@@XZ)".
main.obj : error LNK2001: Nicht aufgelöstes externes Symbol ""public: virtual void * __thiscall MyLegoViewer::qt_metacast(char const *)" (?qt_metacast@MyLegoViewer@@UAEPAXPBD@Z)".
main.obj : error LNK2001: Nicht aufgelöstes externes Symbol ""public: virtual int __thiscall MyLegoViewer::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@MyLegoViewer@@UAEHW4Call@QMetaObject@@HPAPAX@Z)".
debug\Qt.exe : fatal error LNK1120: 3 nicht aufgelöste externe Verweise.
Der Code(erst ein Entwurf ohne viele Implementierungen)
Code: Alles auswählen
#include <QApplication>
#include<QLabel>
#include<QPixmap>
#include<QImage>
#include<QVBoxLayout>
#include<QGridLayout>
#include<QString>
#include<QPushButton>
class MyLegoViewer: public QWidget
{
Q_OBJECT
public:
MyLegoViewer(QWidget* parent=0)
:QWidget(parent)
{
back=new QPushButton("<<");
forward= new QPushButton(">>");
image.load("lego.bmp");
imageholder.setPixmap(QPixmap::fromImage(image));
gridLayout.addWidget(back,0,0);
gridLayout.addWidget(forward,0,1);
boxLayout.addWidget(&imageholder);
boxLayout.addLayout(&gridLayout);
setLayout(&boxLayout);
}
private:
QLabel imageholder;
QImage image;
//QString* filenames;
//int counter;
QPushButton* back;
QPushButton* forward;
QGridLayout gridLayout;
QVBoxLayout boxLayout;
signals:
//void needsUpdate();
public slots:
//void sBack();
//void sForward();
//void update();
};
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
MyLegoViewer window;
window.show();
return app.exec();
}TEMPLATE = app
TARGET +=
DEPENDPATH += .
INCLUDEPATH += .
# Input
SOURCES += main.cpp
Meine Fehler ham verdammte ähnlichkeit mit diesem Thread allerdings hilft rauslöschen bei mir nix: http://www.mrunix.de/forums/archive/ind ... 46852.html
Allerdings zeigt er bei mir in MSVC bei generated Files main.moc und main.moc mit einem roten kreis mit weißer linie vertikal an(dieses lässt sich nicht öffnen)
Das mocFile das sich öffnen lässt:
Was soll ich tun?/****************************************************************************
** Meta object code from reading C++ file 'main.cpp'
**
** Created: Mi 25. Apr 21:23:40 2007
** by: The Qt Meta Object Compiler version 59 (Qt 4.1.4)
**
** WARNING! All changes made in this file will be lost!
*****************************************************************************/
#if !defined(Q_MOC_OUTPUT_REVISION)
#error "The header file 'main.cpp' doesn't include <QObject>."
#elif Q_MOC_OUTPUT_REVISION != 59
#error "This file was generated using the moc from 4.1.4. It"
#error "cannot be used with the include files from this version of Qt."
#error "(The moc has changed too much.)"
#endif
static const uint qt_meta_data_MyLegoViewer[] = {
// content:
1, // revision
0, // classname
0, 0, // classinfo
0, 0, // methods
0, 0, // properties
0, 0, // enums/sets
0 // eod
};
static const char qt_meta_stringdata_MyLegoViewer[] = {
"MyLegoViewer\0"
};
const QMetaObject MyLegoViewer::staticMetaObject = {
{ &QWidget::staticMetaObject, qt_meta_stringdata_MyLegoViewer,
qt_meta_data_MyLegoViewer, 0 }
};
const QMetaObject *MyLegoViewer::metaObject() const
{
return &staticMetaObject;
}
void *MyLegoViewer::qt_metacast(const char *_clname)
{
if (!_clname) return 0;
if (!strcmp(_clname, qt_meta_stringdata_MyLegoViewer))
return static_cast<void*>(const_cast<MyLegoViewer*>(this));
return QWidget::qt_metacast(_clname);
}
int MyLegoViewer::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QWidget::qt_metacall(_c, _id, _a);
if (_id < 0)
return _id;
return _id;
}
Mfg Karldin