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

程梁 chengliang.soft at gmail.com
Thu Apr 29 02:13:37 CEST 2010


> It seems that mainwindow.cpp is properly linked into the libui library.
But
> does it contain the MainWindow destructor and the changeEvent function?

Yes, it does. I can paste code here:

#include <QtPlugin>
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
}
MainWindow::~MainWindow()
{
    delete ui;
}
void MainWindow::changeEvent(QEvent *e)
{
    QMainWindow::changeEvent(e);
    switch (e->type()) {
    case QEvent::LanguageChange:
        ui->retranslateUi(this);
        break;
    default:
        break;
    }
}
Q_EXPORT_PLUGIN2(window, MainWindow);

And I have to say, it seems that Qt try to link the plugin dll statcally.


2010/4/28 Thiago Macieira <thiago at kde.org>

> Em Quarta-feira 28 Abril 2010, às 10:43:36, 程梁 escreveu:
> > Thanks! I found the problem is I forgot add mainwindow.h into app.pro.
> > Then I added the HEADERS, recompiled and there is no such an error.
> >
> > But I got the other error:
> > debug/moc_mainwindow.o:moc_mainwindow.cpp:...: undefined reference to
> > `MainWindow::~MainWindow()'
>
> Find the .cpp file where this function is defined. Ensure it's being linked
> properly into the library.
>
> > / --- test.pro
> >
> >  ui ---- ui.pro
> >
> >   |   | -- mainwindow.h
> >   |   | -- mainwindow.cpp
> >   |   | -- IVisible.h // this contains the interface that has only two
>
> > ui.pro
> > TARGET = ui
> > TEMPLATE = lib
> > CONFIG += plugin
> > DESTDIR = ../app/plugins
> > SOURCES += mainwindow.cpp
> > HEADERS += mainwindow.h \
> >     IVisible.h
> > FORMS += mainwindow.ui
>
> It seems that mainwindow.cpp is properly linked into the libui library. But
> does it contain the MainWindow destructor and the changeEvent function?
>
> --
>  Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
>  Senior Product Manager - Nokia, Qt Development Frameworks
>      PGP/GPG: 0x6EF45358; fingerprint:
>      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>


-- 
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/20100429/823a72df/attachment.html 


More information about the Qt-interest-old mailing list