Important: Please read the Qt Code of Conduct -

Add QDeclarativeView widget to MainWindows.ui cause link error

  • I use Qt Creator (2.1 and 2.2 RC) to create a Qt GUI application by using create project wizard. I have Qt 4.7.3 library installed for Windows XP. After new project created, I build it and successful. But if I drag a QDeclarativeView widget to MainWindows.ui and try to build again and got link errors like:

    MainWindow.obj:-1: error: LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QDeclarativeView::QDeclarativeView(class QWidget *)" (_imp??0QDeclarativeView@@QAE@PAVQWidget@@@Z) referenced in function "public: void __thiscall Ui_MainWindow::setupUi(class QMainWindow *)" (?setupUi@Ui_MainWindow@@QAEXPAVQMainWindow@@@Z)

    What is the problem?

  • Did you add this to you .pro file?

    QT += declarative

  • Yes. Thank you.

  • kathy, "yes" as "yes, I've added it" or as "yes, it solved the problem"?

  • yes, it solved the problem

  • then please don't forget to mark thread as [solved].

Log in to reply