PDA

View Full Version : Combining QML to Qt Application



Veera
5th June 2017, 11:48
Hello!!

I am running a Qt Application in Visual Studio and I would like to combine my QML code into the Qt Application.

I have added qml file in the resources folder of the Qt application and tried to combine it with the following code:


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

When I use this code I get 24 unexpected external symbol errors. I would really appreciate the help!

Thank you!

wysota
6th June 2017, 23:15
What are the errors? What do you have assigned to QT variable in your pro file?

Veera
7th June 2017, 09:54
Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol "__declspec(dllimport) public: __cdecl QQuickView::QQuickView(class QWindow *)" (__imp_??0QQuickView@@QEAA@PEAVQWindow@@@Z) referenced in function "public: __cdecl QtGuiApplication1::QtGuiApplication1(class QWidget *)" (??0QtGuiApplication1@@QEAA@PEAVQWidget@@@Z) QtGuiApplication1 C:\Users\Desktop\QtGuiApplication1\QtGuiApplicatio n1\QtGuiApplication1.obj 1
Error LNK2019 unresolved external symbol "__declspec(dllimport) public: virtual __cdecl QQuickView::~QQuickView(void)" (__imp_??1QQuickView@@UEAA@XZ) referenced in function "public: virtual void * __cdecl QQuickView::`scalar deleting destructor'(unsigned int)" (??_GQQuickView@@UEAAPEAXI@Z) QtGuiApplication1 C:\Users\Desktop\QtGuiApplication1\QtGuiApplicatio n1\QtGuiApplication1.obj 1
Error LNK2019 unresolved external symbol "__declspec(dllimport) public: void __cdecl QQuickView::setSource(class QUrl const &)" (__imp_?setSource@QQuickView@@QEAAXAEBVQUrl@@@Z) referenced in function "public: __cdecl QtGuiApplication1::QtGuiApplication1(class QWidget *)" (??0QtGuiApplication1@@QEAA@PEAVQWidget@@@Z) QtGuiApplication1 C:\Users\Desktop\QtGuiApplication1\QtGuiApplicatio n1\QtGuiApplication1.obj 1
Error LNK2001 unresolved external symbol "public: virtual class QAccessibleInterface * __cdecl QQuickWindow::accessibleRoot(void)const " (?accessibleRoot@QQuickWindow@@UEBAPEAVQAccessible Interface@@XZ) QtGuiApplication1 C:\Users\Desktop\QtGuiApplication1\QtGuiApplicatio n1\QtGuiApplication1.obj 1

I am using Visual Studio with Qt and I think I need not add anything to .pro file.

wysota
7th June 2017, 21:02
And what exactly are you trying to do?


and I think I need not add anything to .pro file.
Great. What do you need from us then?

Veera
9th June 2017, 17:07
I would like to use the Image in QML as a toolbox in the Qt project. I am using Qt with visual studio and I will be glad if someone could help me with the code.

wysota
12th June 2017, 07:12
Linking problems would indicate the code itself is okay. However since you are trying to combine the widget and QtQuick worlds, you surely need to derive your application from QApplication and not QGuiApplication. And for that you need to link against the widgets module.