[Qt-interest] Qt plugin error: undefined reference to `MainWindow::staticMetaObject'

程梁 chengliang.soft at gmail.com
Wed Apr 28 08:39:04 CEST 2010


I tried to create a project. All UI components including MainWindow are in a
plugin dll.
When I loaded this dll using QPluginLoader, there was an compile error:

D:/Develop/Qt/2010.02.1/qt/include/QtCore/../../src/corelib/kernel/qobject.h:455:
undefined reference to `MainWindow::staticMetaObject'

Then I commented qobject_cast<MainWindow *> there is no error and the plugin
loaded successfully.

Here is what I had written in main():

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QPluginLoader pluginLoader("ui.dll");
    if(pluginLoader.load()) {
        QObject *obj = pluginLoader.instance();
        QMessageBox::information(NULL, "plugin",
obj->metaObject()->className());
        // MainWindow *win = qobject_cast<MainWindow *>(obj);
        // win->setVisible(true);
    }
    return a.exec();
}

Could you tell me how to solve this problem? Thank you!

-- 
Cheng Liang
from: chengliang.soft at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100428/f93ff6da/attachment.html 


More information about the Qt-interest-old mailing list