PDA

View Full Version : Linker error when creating custom Property Browser components



stefanadelbert
29th March 2010, 02:07
I'm trying to extend QtPropertyBrowser to accept custom types. I've been following the guide here (http://doc.trolltech.com/qq/qq18-propertybrowser.html).


class CCustomPropertyFactory : public QtVariantEditorFactory {
...
}


class CCustomPropertyManager : public QtVariantPropertyManager {
...
}

I'm getting the following linker error when building my code though:

1>------ Build started: Project: MockClient, Configuration: Debug Win32 ------
1>Linking...
1> Creating library C:\***Client.lib and object C:\***Client.exp
1>clientlib.lib(moc_CCustomPropertyFactory.obj) : error LNK2001: unresolved external symbol "public: static struct QMetaObject const QtVariantEditorFactory::staticMetaObject" (?staticMetaObject@QtVariantEditorFactory@@2UQMeta Object@@B)
1>clientlib.lib(moc_CCustomPropertyManager.obj) : error LNK2001: unresolved external symbol "public: static struct QMetaObject const QtVariantPropertyManager::staticMetaObject" (?staticMetaObject@QtVariantPropertyManager@@2UQMe taObject@@B)
1>C:\***Client.exe : fatal error LNK1120: 2 unresolved externals
1>Build log was saved at "file://c:\****\Debug\BuildLog.htm"
1>MockClient - 3 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 3 up-to-date, 0 skipped ==========

It looks like there is a reference to the staticMetaObject in moc_CCustomPropertyFactory.cpp.


const QMetaObject Epoch::CCustomPropertyFactory::staticMetaObject = {
{ &QtVariantEditorFactory::staticMetaObject, qt_meta_stringdata_Epoch__CCustomPropertyFactory,
qt_meta_data_Epoch__CCustomPropertyFactory, 0 }
};

But staticMetaObject is only declared (in qobject.h) if qdoc is defined. Should qdoc be defined?


#ifdef qdoc
static QString tr(const char *sourceText, const char *comment = 0, int n = -1);
static QString trUtf8(const char *sourceText, const char *comment = 0, int n = -1);
virtual const QMetaObject *metaObject() const;
static const QMetaObject staticMetaObject;
#endif

I'm using Qt 4.6.2, QtPropertyBrowser 2.5.1, VS 2008, Windows 7.

Any help would be much appreciated.

Thanks
Stefan

stefanadelbert
29th March 2010, 03:50
I've managed to get around this issue by building QtPropertyBrowser as a static rather than dynamic library and it now works fine in my main project. I suppose this suggests that the problem with dll import-/export and is possibly somehow linked to QT_QTPROPERTYBROWSER_IMPORT/QT_QTPROPERTYBROWSER_EXPORT, which seems to have caused some problems in the past.