[SOLVED] Qt Quick Application: empty window
-
wrote on 14 Jul 2011, 12:34 last edited by
Default project 'Qt Quick Application' created and maked. It shows "Hello World" on 'Ctrl+R', but exe running give empty window. Any idea? Thanks!
-
wrote on 14 Jul 2011, 12:40 last edited by
Looks like your qmls are located in wrong path.
-
wrote on 14 Jul 2011, 12:44 last edited by
Unfortuantely the default project does not pack the qml file into a resource. That means the qml-file may get lost easily. The build script has deployment options to copy the qml file, however I find this very brittle. Bottom line:
- Make sure that the qml file is located where it is expected by the executable.
- To get a stable solution put the qml file in a resource.
-
wrote on 14 Jul 2011, 12:55 last edited by
Ok. Thank you!
Can you explain me about putting qml into resource, please? -
wrote on 14 Jul 2011, 13:15 last edited by
Sure:
Select in Creator: File->New->Qt->Resource file
This will add a resource file to your project and give you a graphical editor that permits to select files which will be included in the binary file. Next step is to access the files that reside inside your executable:As URL:
@QDeclarativeView view;
view.setSource(QUrl("qrc:qml/myqmlfile.qml"));@To access the file itself:
@QFile file(":qml/myqmlfile.qml");@ -
wrote on 14 Jul 2011, 13:41 last edited by
Yeah! Excellent! Thanks a lot!
-
wrote on 16 Sept 2014, 02:33 last edited by
I'm having the same issue, but these suggestions didn't help.
I'm using the newest version of QT Creator on Windows 8.
It works perfectly if I go to the debug build directory and double click on the .exe file, but when I run the applications from Qt Creator using the big great play button it just shows an empty window.
-
wrote on 25 Sept 2014, 19:50 last edited by
The latest versions of Qt Creator take care of the original problem stated here because the main.qml file is put inside a qml.qrc resource file by default. Did yours do this? If not you might not be on the latest (right now 5.2.3 - but its been doing this for a while). Other than that I would suggest taking a look at the Projects mode and switch to the Run tab and see if possibly something got mucked up on the Working Directory line. It should point to that same folder where you are manually double-clicking.