July 14, 2011

Sht1rlitz Sht1rlitz
Lab Rat
11 posts

[SOLVED] Qt Quick Application: empty window

 

Default project ‘Qt Quick Application’ created and maked. It shows “Hello World” on ‘Ctrl+R’, but exe running give empty window. Any idea? Thanks!

5 replies

July 14, 2011

Denis Kormalev Denis Kormalev
Lab Rat
1654 posts

Looks like your qmls are located in wrong path.

July 14, 2011

dialingo dialingo
Lab Rat
158 posts

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.

July 14, 2011

Sht1rlitz Sht1rlitz
Lab Rat
11 posts

Ok. Thank you!
Can you explain me about putting qml into resource, please?

July 14, 2011

dialingo dialingo
Lab Rat
158 posts

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:

  1. QDeclarativeView view;
  2. view.setSource(QUrl("qrc:qml/myqmlfile.qml"));

To access the file itself:

  1. QFile file(":qml/myqmlfile.qml");

July 14, 2011

Sht1rlitz Sht1rlitz
Lab Rat
11 posts

Yeah! Excellent! Thanks a lot!

 
  ‹‹ ListView model binding to QAbstractListModel derived model      Qt:key enum problem ››

You must log in to post a reply. Not a member yet? Register here!