Noob Question: What's up with QtQuick.Window ?



  • Hi... coming from the C++ side of Qt, I'm now looking at QtQuick, and going through the examples. One Caveat I've found is that the template in QtCreator imports QtQuick.Window, and apparently the root element needs to be called Window. Not having this, my programs execute but nothing comes up.

    As per the docs:
    [quote]Omitting this import will allow you to have a QML environment without access to window system features.
    [/quote]

    Most of the examples don't have this. They don't import QtQuick.Window, start with Rectangle, and go from there. I generally like following tutorials to a T with something new, and am wondering if I"m missing something. The tutorials states you should be able to view these, but when I run them from Creator, I don't. :-/


  • Moderators

    Hi,

    AFAIK, From Qt 5.3, QtCreator creates a project with Window component as default root Object.
    Since Window is just a container you should add an Item to it For eg. a Rectangle. Try adding it and you will see a Rectangle.

    Also if you want don't want Window as root object you can replace it with Rectangle but then you will have to use QQuickView instead of QQmlApplicationEngine to load the QML.



  • Thanks for the reply. I assume QQuickView is used you make a "QT Quick UI" as opposed to a "QT Quick Application" in creator. I can probably live either way for now. :)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.