PDA

View Full Version : Add .qml to myWindow



jeff28
28th August 2012, 09:19
Hi, I am trying to use my .qml files in QWidget. I have myWindow which is a widget. I would like to be able to use my .qml file and change with different methods. I am not sure how to view my .qml file? Should I define a QDeclarativeView item in my header file and read .qml in constructor? Can you guys give me some advice?

spirit
28th August 2012, 09:38
QDeclarativeView
The QDeclarativeView class provides a widget for displaying a Qt Declarative user interface..
So, yes, you should use QDeclarativeView.

jeff28
28th August 2012, 10:07
Exactly I used it. I have a QDeclarativeView object(called viewer) in myWindow widget. In the constructor of myWindow I called the setSource method with my .qml file. But when I compile it another window also opens for my .qml file but there isn't anything in it.( There should be a simple picture)

spirit
28th August 2012, 10:12
Are you sure that a path to *.qml file is correct? :)

jeff28
28th August 2012, 10:16
Well now I am not sure :) I typed in "QUrl::fromLocalFile("main.qml")" in my setSource method. In all of the examples that I saw it was like this so I did like that too..