Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. What is the difference between QML Rectangle and Window?
Forum Updated to NodeBB v4.3 + New Features

What is the difference between QML Rectangle and Window?

Scheduled Pinned Locked Moved QML and Qt Quick
1 Posts 1 Posters 2.4k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • X Offline
    X Offline
    xalam
    wrote on last edited by
    #1

    I create a new Qt Quick application with default basic code. Now if I only replace 'Window' below with`Rectangle', this application never runs..more accurately it runs in the background but GUI never shows up.

    What really is the difference between Window or Rectangle? Why does the application behaviors changes so much that it doesn't even run properly?

    @import QtQuick 2.3
    import QtQuick.Window 2.2

    Window {
    visible: true
    width: 360
    height: 360

    MouseArea {
        anchors.fill: parent
        onClicked: {
            Qt.quit();
        }
    }
    
    Text {
        text: qsTr("Hello World")
        anchors.centerIn: parent
    }
    

    }@

    The main.cpp file is here

    @#include <QGuiApplication>
    #include <QQmlApplicationEngine>

    int main(int argc, char *argv[])
    {
    QGuiApplication app(argc, argv);

    QQmlApplicationEngine engine;
    engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
    
    return app.exec&#40;&#41;;
    

    }@

    1 Reply Last reply
    1

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved