Hello QT Geeks!
I have to create GUI for my application and after re-search I've had to choose between wxWidgets and QT, and my choice was QT.
I've downloaded newest QT Version from http://qt.nokia.com (i.e. 4.6.3), MinGW 5.1.6 and Code::Blocks (Also latest version.) and I'm working on Windows XP Professional Service Pack 3.
I've configured my Code::Blocks using some wiki tutorial (Can't remember where did I find the link so can't post :/).
Basically I need 2 "windows" in 2 classes:
a) Login Window with 2 static texts, 2 text boxes and 3 push buttons.
b) Client window with few tabs, buttons and such.
Here's my code:
main.cpp:
#include <QApplication>
#include "LoginInterface.h"
int main(int argc, char *argv[])
{
LoginInterface li;
li.show();
return app.exec();
}
#include <QApplication>
#include "LoginInterface.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
LoginInterface li;
li.show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
LoginInterface.cpp:
#include <QLabel>
#include "LoginInterface.h"
LoginInterface::LoginInterface()
{
NameDialog->show();
}
#include <QLabel>
#include "LoginInterface.h"
LoginInterface::LoginInterface()
{
QLabel *NameDialog = new QLabel(tr("Name:"));
NameDialog->show();
}
To copy to clipboard, switch view to plain text mode
LoginInterface.h:
#ifndef LOGININTERFACE_H
#define LOGININTERFACE_H
#include <QMainWindow>
{
Q_OBJECT
public:
LoginInterface();
};
#endif
#ifndef LOGININTERFACE_H
#define LOGININTERFACE_H
#include <QMainWindow>
class LoginInterface : public QMainWindow
{
Q_OBJECT
public:
LoginInterface();
};
#endif
To copy to clipboard, switch view to plain text mode
As you can see in LoginInterface header file, there's Q_OBJECT variable, but with this variable I'm getting following errors:
obj\LoginInterface.o:LoginInterface.cpp:(.text+0x66): undefined reference to `LoginInterface::staticMetaObject'
obj\LoginInterface.o:LoginInterface.cpp:(.text+0x71): undefined reference to `vtable for LoginInterface'
obj\LoginInterface.o:LoginInterface.cpp:(.text+0x78): undefined reference to `vtable for LoginInterface'
obj\LoginInterface.o:LoginInterface.cpp:(.text+0x1f8): undefined reference to `vtable for LoginInterface'
obj\LoginInterface.o:LoginInterface.cpp:(.text+0x1ff): undefined reference to `vtable for LoginInterface'
obj\LoginInterface.o:LoginInterface.cpp:(.text+0x213): undefined reference to `LoginInterface::staticMetaObject'
obj\LoginInterface.o:LoginInterface.cpp:(.text+0x66): undefined reference to `LoginInterface::staticMetaObject'
obj\LoginInterface.o:LoginInterface.cpp:(.text+0x71): undefined reference to `vtable for LoginInterface'
obj\LoginInterface.o:LoginInterface.cpp:(.text+0x78): undefined reference to `vtable for LoginInterface'
obj\LoginInterface.o:LoginInterface.cpp:(.text+0x1f8): undefined reference to `vtable for LoginInterface'
obj\LoginInterface.o:LoginInterface.cpp:(.text+0x1ff): undefined reference to `vtable for LoginInterface'
obj\LoginInterface.o:LoginInterface.cpp:(.text+0x213): undefined reference to `LoginInterface::staticMetaObject'
To copy to clipboard, switch view to plain text mode
But when I remove that (Yea I know, ugly cheat. :p), everything compiles fine, but GUI comes with separated windows, like on this screen:

Is there any way to fix Q_OBJECT thing and fix windows, so new controls will be CHILDS, not separated windows?
Also I've tried other ready code and C::B threw me error about 'Undefined QThread' or something, do I miss some parts of QT or?
Cheers, Diath.
PS: I hope you'll understand my english, it's kinda bad but i tried to write as proper as I can.
Bookmarks