QML front end in CPP: compile/linker trouble



  • I am using VS2010 with qt 5.2.1

    I have been working on a UI in QML and trying to integrate it into my C++ project, I tried

    @#include <QDeclarativeView>@

    like "this suggests doing.":http://qt-project.org/doc/qt-4.8/qdeclarativeview.html#details

    however, I get compiler errors saying that QDeclarativeView cannot be found. so I googled and after adding

    @QT+= quick@

    didn't work,was tried a QQuickView instead. this time including QtQuick/QQuickView worked. so I tried the following

    @ QQuickView *view = new QQuickView;
    view->setSource(QUrl::fromLocalFile("main.qml");
    view->show();@

    and this gets all sorts of ridiculous linker errors, and now I have no idea what to try.

    @2>MainWindow.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall QQuickView::setSource(class QUrl const &)" (_imp?setSource@QQuickView@@QAEXABVQUrl@@@Z) referenced in function "public: __thiscall MainWindow::MainWindow(void)" (??0MainWindow@@QAE@XZ)
    2>MainWindow.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QQuickView::QQuickView(class QWindow *)" (_imp??0QQuickView@@QAE@PAVQWindow@@@Z) referenced in function "public: __thiscall MainWindow::MainWindow(void)" (??0MainWindow@@QAE@XZ)
    2>MainWindow.obj : error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall QQuickView::metaObject(void)const " (?metaObject@QQuickView@@UBEPBUQMetaObject@@XZ)
    2>MainWindow.obj : error LNK2001: unresolved external symbol "public: virtual void * __thiscall QQuickView::qt_metacast(char const *)" (?qt_metacast@QQuickView@@UAEPAXPBD@Z)
    2>MainWindow.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall QQuickView::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@QQuickView@@UAEHW4Call@QMetaObject@@HPAPAX@Z)
    2>MainWindow.obj : error LNK2001: unresolved external symbol "protected: virtual bool __thiscall QQuickWindow::event(class QEvent *)" (?event@QQuickWindow@@MAE_NPAVQEvent@@@Z)
    2>MainWindow.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QQuickView::timerEvent(class QTimerEvent *)" (?timerEvent@QQuickView@@MAEXPAVQTimerEvent@@@Z)
    2>MainWindow.obj : error LNK2001: unresolved external symbol "public: virtual class QAccessibleInterface * __thiscall QQuickWindow::accessibleRoot(void)const " (?accessibleRoot@QQuickWindow@@UBEPAVQAccessibleInterface@@XZ)
    2>MainWindow.obj : error LNK2001: unresolved external symbol "public: virtual class QObject * __thiscall QQuickWindow::focusObject(void)const " (?focusObject@QQuickWindow@@UBEPAVQObject@@XZ)
    2>MainWindow.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QQuickWindow::exposeEvent(class QExposeEvent *)" (?exposeEvent@QQuickWindow@@MAEXPAVQExposeEvent@@@Z)
    2>MainWindow.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QQuickView::resizeEvent(class QResizeEvent *)" (?resizeEvent@QQuickView@@MAEXPAVQResizeEvent@@@Z)
    2>MainWindow.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QQuickWindow::focusInEvent(class QFocusEvent *)" (?focusInEvent@QQuickWindow@@MAEXPAVQFocusEvent@@@Z)
    2>MainWindow.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QQuickWindow::focusOutEvent(class QFocusEvent *)" (?focusOutEvent@QQuickWindow@@MAEXPAVQFocusEvent@@@Z)
    2>MainWindow.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QQuickWindow::showEvent(class QShowEvent *)" (?showEvent@QQuickWindow@@MAEXPAVQShowEvent@@@Z)
    2>MainWindow.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QQuickWindow::hideEvent(class QHideEvent *)" (?hideEvent@QQuickWindow@@MAEXPAVQHideEvent@@@Z)
    2>MainWindow.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QQuickView::keyPressEvent(class QKeyEvent *)" (?keyPressEvent@QQuickView@@MAEXPAVQKeyEvent@@@Z)
    2>MainWindow.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QQuickView::keyReleaseEvent(class QKeyEvent *)" (?keyReleaseEvent@QQuickView@@MAEXPAVQKeyEvent@@@Z)
    2>MainWindow.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QQuickView::mousePressEvent(class QMouseEvent *)" (?mousePressEvent@QQuickView@@MAEXPAVQMouseEvent@@@Z)
    2>MainWindow.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QQuickView::mouseReleaseEvent(class QMouseEvent *)" (?mouseReleaseEvent@QQuickView@@MAEXPAVQMouseEvent@@@Z)
    2>MainWindow.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QQuickWindow::mouseDoubleClickEvent(class QMouseEvent *)" (?mouseDoubleClickEvent@QQuickWindow@@MAEXPAVQMouseEvent@@@Z)
    2>MainWindow.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QQuickView::mouseMoveEvent(class QMouseEvent *)" (?mouseMoveEvent@QQuickView@@MAEXPAVQMouseEvent@@@Z)
    2>MainWindow.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QQuickWindow::wheelEvent(class QWheelEvent *)" (?wheelEvent@QQuickWindow@@MAEXPAVQWheelEvent@@@Z)
    2>MainWindow.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall QQuickView::~QQuickView(void)" (_imp??1QQuickView@@UAE@XZ) referenced in function "public: virtual void * __thiscall QQuickView::`scalar deleting destructor'(unsigned int)" (??_GQQuickView@@UAEPAXI@Z)@



  • Can you try putting QT += qml quick as well ? Suggest you clean and rebuild. Can you try creating the QtQuick UI application itself ? This puts all the necessary things for you.



  • QT += qml quick placed, tried a clean and rebuild, same linker errors. What do you mean by create the application itself?



  • Never mind, My problem is related to Visual Studio's property sheets mess because of the way my project is setup. I have to follow some other steps to link correctly.


  • Moderators

    Try
    @
    #include <QtQuick>
    @


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.