How to use a QQuickView class in Qt 5.12.3?
-
Hi, I tried an example code and got some error occured.
Please, Help me.
Here is my code.#include <QGuiApplication> #include <QQuickView> #include <QUrl> int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); QQuickView *pView = new QQuickView(); pView->setSource(QUrl::fromLocalFile("main.qml")); pView->show(); return app.exec(); }
with this code, I got two error.
One: "incomplete type 'QUrl' named in nested name specifier."
pView->setSource(QUrl::fromLocalFile("main.qml"));
Two: "no member named 'show' in QQuickView."
pView->show();
For problem number one, I tried to find what namespace has the QUrl class.
I found two define 'QT_BEGIN_NAMESPACE' and 'QT_END_NAMESPACE', I've never seen before.
I have no idea how to use it, but also no mention about it in examples.I am using Qt 5.12.3 that seems the reason of problem number two and I couldn't tell how to use it in this Qt version.
How can I use the QQuickView class?
Where can I look for some advises or references for that? -
@sinsisao
I just run your code, except a warning that main.qml could not be found ( as I don't have one)main.qml: No such file or directory
It's working fine. Everything is detected and the program executes and shows the(empty) quickview just fine.
Qt 5.12.2 & 5.12.3 on MacOS