[SOLVED] How to displaying QML file in widget
-
[quote author="JKSH" date="1399458692"]# Are you using an OpenGL version of Qt, or an ANGLE version?
Does your graphics card support OpenGL 2.0?
In Qt Creator, start a new Qt Quick project:
File -> New File or Project... -> Applications -> Qt Quick Application -> Qt Quick 2.2
Click "Run. What do you see?
[/quote]
It's Angle version , not OpenGL
About My GPU : (AMD Readon HD 6670) OPENGL 4.1 SUPPORT : Yes
In Qt Creator I have Qt Quick 2.2
After create and run this is result : http://persianupload.com/kleeja/do.php?imgf=13994592497651.jpg -
[quote author="Kamb!z" date="1399459302"]After create and run this is result : http://persianupload.com/kleeja/do.php?imgf=13994592497651.jpg[/quote]Good, it's working :)
If you still want to use QWidgets, add "QT += widgets" to your untitled26.pro and try QQuickView/QQuickWidget again.
EDIT: What version of Qt Creator are you using? Your project looks different
-
[quote author="JKSH" date="1399459696"][quote author="Kamb!z" date="1399459302"]After create and run this is result : http://persianupload.com/kleeja/do.php?imgf=13994592497651.jpg[/quote]Good, it's working :)
If you still want to use QWidgets, add "QT += widgets" to your untitled26.pro and try QQuickView/QQuickWidget again.
EDIT: What version of Qt Creator are you using? Your project looks different[/quote]
Unfortunately doesn't work ! :( content of QML file is a string ("Hello world") but isn't show.
See : http://persianupload.com/kleeja/do.php?imgf=139946053737491.jpg
and my project : http://persianupload.com/kleeja/do.php?filename=139946053748452.zip
-
Your URL is wrong.
Look inside main.cpp -- the correct URL is written there.
-
[quote author="JKSH" date="1399462036"]Your URL is wrong.
Look inside main.cpp -- the correct URL is written there.[/quote]
This is main address of qml file : qrc:///qml/main.qml
view->setSource(QUrl::fromLocalFile("qrc:///qml/main.qml"));
can you check my sample of code ! this is : http://persianupload.com/kleeja/do.php?filename=139946053748452.zip
-
[quote author="Kamb!z" date="1399462538"]view->setSource(QUrl::fromLocalFile("qrc:///qml/main.qml"));[/quote]You shouldn't use QUrl::fromLocalFile(), because items in QRC files are not local files. See main.cpp for the correct way of calling QUrl.
Also, open main.qml and change Window {} to Rectangle {} -- that will make things easier for you.
-
Not working for me again ! Can you give me a sample ? please !
I want to compare your project with mine. -
@
// mainwindow.cpp
// Change this...
QUrl::fromLocalFile("qrc:///qml/main.qml")// ...to this:
QUrl(QStringLiteral("qrc:///qml/main.qml"))
@@
// main.qml
// Change this...
Window {
...// ...to this:
Rectangle {
@ -
[quote author="JKSH" date="1399468987"]@
// mainwindow.cpp
// Change this...
QUrl::fromLocalFile("qrc:///qml/main.qml")// ...to this:
QUrl(QStringLiteral("qrc:///qml/main.qml"))
@@
// main.qml
// Change this...
Window {
...// ...to this:
Rectangle {
@[/quote]Oh yes !!! I understand now ! thank you JKSH :)
-
You're welcome :) Happy coding!