Results 1 to 5 of 5

Thread: Add .qml to myWindow

  1. #1
    Join Date
    Aug 2012
    Posts
    30
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Add .qml to myWindow

    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?

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Add .qml to myWindow

    QDeclarativeView
    The QDeclarativeView class provides a widget for displaying a Qt Declarative user interface.
    .
    So, yes, you should use QDeclarativeView.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. #3
    Join Date
    Aug 2012
    Posts
    30
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Add .qml to myWindow

    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)

  4. #4
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Add .qml to myWindow

    Are you sure that a path to *.qml file is correct?
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  5. The following user says thank you to spirit for this useful post:

    jeff28 (28th August 2012)

  6. #5
    Join Date
    Aug 2012
    Posts
    30
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Add .qml to myWindow

    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..

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.