AdvancingEnemy
AdvancingEnemy

Reputation: 422

how to set the QML application window transparent by Qt 5.6?

I am new in Qt & QML, now I set a window and want to set it transparent, user can see my desktop cross my application. I try to use WA_TranslucentBackground and opacity, however it doesn't work.

Here is my QML code, it's very simple:

import QtQuick 2.6
import QtQuick.Window 2.2
import QtQuick.Controls 1.4

Window {
    visible: true
    width: Screen.width
    height: Screen.height
    title: qsTr("Input")
    flags: Qt.WA_TranslucentBackground | Qt.FramelessWindowHint

    MouseArea {
        anchors.fill: parent
        onClicked: {
            Qt.quit();
        }
    }

    Text {
        text: qsTr("Hello World")
        anchors.centerIn: parent
    }
}

Upvotes: 2

Views: 2321

Answers (1)

folibis
folibis

Reputation: 12874

Window {
    visible: true
    color: "transparent"
    //flags: Qt.Widget | Qt.FramelessWindowHint
}

Uncomment flags if you want transparent window without frame

Upvotes: 3

Related Questions