Jung San
Jung San

Reputation: 23

Nothing gets displayed when running a Qt QML project

I'm using Qt QML in Qt Creator, and nothing gets displayed when I run my main.qml:

main.qml:

import QtQuick 
import QtQuick.Window 
import QtQuick.VirtualKeyboard

Window {
    width: 100
    height: 100

    Rectangle {
        color: "red"
        anchors.fill: parent

    }
}

The output in the terminal:

11:22:25: Démarrage de C:\Users\azus\Documents\build-sans_titre2-Desktop_Qt_6_4_3_MinGW_64_bit-Debug\appsans_titre2.exe...

Upvotes: 0

Views: 107

Answers (2)

user17726418
user17726418

Reputation: 2365

Window needs to be set visible, and you could do it this way:

import QtQuick 
import QtQuick.Window 
import QtQuick.VirtualKeyboard

Window {
    width: 100
    height: 100
    visible: true

    Rectangle {
        color: "red"
        anchors.fill: parent

    }
}

Upvotes: 0

Mike
Mike

Reputation: 565

import QtQuick 2.12
import QtQuick.Window 2.12

Window {
    width: 100
    height: 100
    Rectangle {
        color: "red"
        anchors.fill: parent

    }
    visible: true
}

This builds and shows a red window on Ubuntu 20.04, QT 5.12.12. I have to specify the 2.12 on my system.

Upvotes: 0

Related Questions