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

爷,独闯天下 提交于 2019-12-24 05:06:08

问题


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

回答1:


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

Uncomment flags if you want transparent window without frame



来源:https://stackoverflow.com/questions/41136178/how-to-set-the-qml-application-window-transparent-by-qt-5-6

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!