[solved]Testing ApplicationWindow.visibility enum values?



  • Very basic question:

    I am playing around with making a routine to toggle a QtQuick app fullscreen (code below) and find that I can't test the enum QWindow::Visibility by the const name but only by the value. i.e. I can't do this: if ( window.visibility == QWindow.FullScreen)

    I must be doing it wrong but I've tried a few syntax variations.

    (alternately, is there a cleaner way of doing what I am trying to do?)

    import QtQuick.Controls 1.4
    
    ApplicationWindow {
        id: window
        visible: true
        visibility: "Windowed"
        width: 1024
        height: 768
    
        Button {
             id: button
            text: "FullScreen"
            onClicked: toggleFullScreen()
        }
    
        function toggleFullScreen(){
              console.log(window.visibility)
    
           if ( window.visibility == 5){
               window.visibility = "Windowed"
               button.text = "FullScreen"
    
           } else if ( window.visibility == 2){
               window.visibility = "FullScreen"
               button.text = "Windowed"
           }
        }
    }

  • Moderators

    Hi @TOMATO_QT
    You can use Window.FullScreen or Window.Windowed. Just import QtQuick.Window 2.0 or greater.



  • @p3c0

    Hey thanks! Works as expected.
    Another baby step on the road to writing more interesting bugs. . . ;-)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.