如何将弹出窗口背景颜色设置为透明

3
当游戏结束时,我希望弹出以下内容:
Popup {
    id: popup
    anchors.centerIn: parent
    Text{
        text: "Game Over!!" + "\n\n" + "New High Score: "+ score_val
        anchors.centerIn: canvas
        color: "grey"
        font.pixelSize: 70
        font.family: gill.name
    }
    modal: true
    focus: true
    closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent

}

一切都很好,但背景是白色的,似乎没有背景颜色属性,我该怎么办?


创建发布的按钮上写着“提问”,而不是“提问”。所以如果你有多个问题,就要创建多个帖子。另外,像“qml”这样的标签不应该出现在标题中,因为那是标签的部分。最后,Qt Quick Controls 1 中没有弹出窗口,但在 Qt Quick Controls 2 中有,所以你必须使用 qtquickcontrols2 标签,以便未来的读者能够轻松找到你的问题。 - eyllanesc
1个回答

4

您需要将一个项目设置为background属性:

Popup {
    id: popup
    anchors.centerIn: parent
    Text{
        text: "Game Over!!" + "\n\n" + "New High Score: "+ score_val
        anchors.centerIn: canvas
        color: "grey"
        font.pixelSize: 70
        font.family: gill.name
    }
    <b>background: Rectangle {
        color: "transparent"
        border.color: "black"
    }</b>
    modal: true
    focus: true
    closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent
}

如果不需要边框,可以将其设置为空的Item{} - Mariusz Jaskółka

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接