Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Change popup background to transparent



  • I have the following popup to appear when the game finishes:

    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
        }
    

    It's all good but the background is white and there seems no background color property, what should I do?

    and I can't center align the text ,how do I make it centered if it's multiple lines?



  • @newbiSoso I think you have to play with the background property, something like this:

    Popup {
        id: popup
        anchors.centerIn: parent
        background: Rectangle {
                anchors.fill: popup
                border.color: "black"
                color: "transparent"
        }
        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
    }
    

Log in to reply