PDA

View Full Version : Compilation Error: base class undefined in the class created from UI file



richardander
27th December 2008, 11:58
Hi,

I am porting my Qt3.3 program to Qt4.4.3. I used qt3to4 program to compile my .pro file and run qmake to created a vc++ project.

One of the form (UI files in .PRO file) is compile and created a class, Ui::MainWindow.

Based on this, a new class is defined as in mainwindow.h file.


class MainWindow : public Q3MainWindow, public Ui::MainWindow
{
Q_OBJECT

public:
MainWindow(QWidget* parent = 0, const char* name = 0, Qt::WindowFlags fl = Qt::WType_TopLevel);
~MainWindow();

protected slots:
virtual void languageChange();

};

In mainwindow.cpp file, it has:


#include ...

MainWindow::MainWindow(QWidget* parent, const char* name, Qt::WindowFlags fl)
: Q3MainWindow(parent, name, fl)
{
setupUi(this);

(void)statusBar();
}
...

In my program, I defined a new class as following in TestMainWindow.h


#include "mainwindow.h"
....
class TestMainWindow : public MainWindow
{
Q_OBJECT

public:
TestMainWindow ( QWidget* parent = 0, const char* name = 0, Qt::WFlags fl = Qt::WType_TopLevel ); // | WStyle_Customize | WStyle_NoBorder
~TestMainWindow();

...
}


In compilation, I always get error that

c:\project\TestMainWindow.h(19) : error C2504: 'MainWindow' : base class undefined

I open the "mainwindow.h", it exists and in the include path.

Could anyone help me find out the problem?

Thank you very much!

Richard -

jpn
27th December 2008, 12:03
Add
QT += qt3support
to the .pro file and re-run qmake.

richardander
27th December 2008, 18:47
Thank you for the input!

Actually, QT += qt3support, has been added to .PRO file.

Any other thoughts?

Thank you!

richardander
27th December 2008, 19:34
some additional info:

this error happens when it compiles moc_TestMainwindow.cpp.

Thank you!

Richard