Details
-
Bug
-
Resolution: Invalid
-
Not Evaluated
-
None
-
Some Release
-
None
-
MacBook Pro
Windows Vista
Visual Studio 2008
QtCreator 1.2
Description
When I subclass QtPropertyTreeBrowser and add the Q_OBJECT macro, I get the following linker error:
moc_mainwindow.obj:-1: error: unresolved external symbol "public: static struct QMetaObject const QtTreePropertyBrowser::staticMetaObject" (?staticMetaObject@QtTreePropertyBrowser@@2UQMetaObject@@B)
I need to do this so I can add a slot that gets connected to, for example, the QtBoolPropertyManager::valueChanged() signal.
To reproduce:
1. Start a new GUI application in Qt Creator.
2. In MainWindow.h, add the following class:
#include <QtTreePropertyBrowser>
class MyPropertyBrowser : public QtTreePropertyBrowser
{
Q_OBJECT
public:
MyPropertyBrowser(QWidget* parent = 0) : QtTreePropertyBrowser(parent) {}
~MyPropertyBrowser() {}
};
3. In MainWindow.cpp, edit the constructor:
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent), ui(new Ui::MainWindow)
{
ui->setupUi(this);
MyPropertyBrowser* browser = new MyPropertyBrowser(this);
}
4. Update the project file:
LIBS += -LPropertyEditor\lib -lQtSolutions_PropertyBrowser-2.5d
INCLUDEPATH += PropertyEditor\src
5. Build.
If you comment out Q_OBJECT, the linker error doesn't occur.