QQuickWindow transparent

前端 未结 3 928
醉话见心
醉话见心 2021-01-05 02:40

im using QQmlApplicationEngine with QQuickWindow for an application and i can\'t transparent main window. i want to set a splash before application pops up and i use Window

3条回答
  •  礼貌的吻别
    2021-01-05 03:30

    One has to realize that a Window QtQuick type maps to QQuickWindow C++ class, and derives from QWindow. The window flags, per Cameron's answer, can be set. But you also need to set the opacity to, say, 0.75 to make it translucent. All of this can be done in QML, no need for setting flags from C++.

    screenshot

    import QtQuick 2.1
    import QtQuick.Controls 1.0
    import QtQuick.Window 2.0
    
    ApplicationWindow {
        title: qsTr("Hello World")
        width: 640
        height: 480
        flags: Qt.SubWindow | Qt.Tool | Qt.FramelessWindowHint | Qt.WindowSystemMenuHint | Qt.WindowStaysOnTopHint
        opacity: 0.75
        visible: true
        menuBar: MenuBar {
            Menu {
                title: qsTr("File")
                MenuItem {
                    text: qsTr("Exit")
                    onTriggered: Qt.quit();
                }
            }
        }
        Button {
            text: "Hello World"
            anchors.centerIn: parent
        }
    }
    

提交回复
热议问题