Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. how to set fullscreen mode of a qml rectangle?
Forum Updated to NodeBB v4.3 + New Features

how to set fullscreen mode of a qml rectangle?

Scheduled Pinned Locked Moved Solved QML and Qt Quick
10 Posts 3 Posters 1.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • JoeCFDJ Offline
    JoeCFDJ Offline
    JoeCFD
    wrote on last edited by JoeCFD
    #1

    I put the following code into a small test qml app. It works fine. But the same code fails after it is inserted into a rectangle of a large project. What could block the change to fullscreen mode? I have made sure the state change is triggered and its change is printed on the screen with console.log

        states: [
            State {
                name: "EXPANDED"
                PropertyChanges { target: rect; x: 0 }
                PropertyChanges { target: rect; y: 0 }
                PropertyChanges { target: rect; width:  Screen.width }
                PropertyChanges { target: rect; height: Screen.height }
            }
        ]
    
        transitions: [
            Transition {
                ParallelAnimation {
                    NumberAnimation { target: rect; property: "x";      duration: 400 }
                    NumberAnimation { target: rect; property: "y";      duration: 400 }
                    NumberAnimation { target: rect; property: "width";  duration: 400 }
                    NumberAnimation { target: rect; property: "height"; duration: 400 }
                }
            }
        ]
    
        MouseArea {
            anchors.fill: rect
            onClicked: {
                rect.state = rect.state === "EXPANDED" ? "" : "EXPANDED"
            }
        }
    
    
    1 Reply Last reply
    0
    • JoeCFDJ Offline
      JoeCFDJ Offline
      JoeCFD
      wrote on last edited by
      #2

      I managed to change its size to full screen one, but can not move it to Point(0,0). This rectangle is inside an Item and created with a loader.

      1 Reply Last reply
      0
      • GrecKoG Offline
        GrecKoG Offline
        GrecKo
        Qt Champions 2018
        wrote on last edited by
        #3

        Define "it fails".
        What is the expected result and what is the actual result?

        What is the parent of your rectangle?

        JoeCFDJ 1 Reply Last reply
        1
        • fcarneyF Offline
          fcarneyF Offline
          fcarney
          wrote on last edited by
          #4
          states: [
                  State {
                      name: "EXPANDED"
                      // these can be done in same property change:
                      PropertyChanges { 
                          target: rect 
                          x: 0 
                          y: 0
                          width:  <parentid>.width
                          height: <parentid>.height
                      }
                  }
              ]
          

          Would anchor changes be better?

          AnchorChanges {
              target: rect
              anchors.fill: <parentid>
          }
          

          C++ is a perfectly valid school of magic.

          JoeCFDJ 1 Reply Last reply
          1
          • GrecKoG GrecKo

            Define "it fails".
            What is the expected result and what is the actual result?

            What is the parent of your rectangle?

            JoeCFDJ Offline
            JoeCFDJ Offline
            JoeCFD
            wrote on last edited by
            #5

            @GrecKo It fails because it is not resized to fullscreen. There are a few layers of layout. Its parent is not the main window.

            1 Reply Last reply
            0
            • fcarneyF Offline
              fcarneyF Offline
              fcarney
              wrote on last edited by
              #6

              @JoeCFD said in how to set fullscreen mode of a qml rectangle?:

              Its parent is not the main window.

              Then maybe you can try a parent change as well.

              C++ is a perfectly valid school of magic.

              JoeCFDJ 1 Reply Last reply
              1
              • fcarneyF fcarney
                states: [
                        State {
                            name: "EXPANDED"
                            // these can be done in same property change:
                            PropertyChanges { 
                                target: rect 
                                x: 0 
                                y: 0
                                width:  <parentid>.width
                                height: <parentid>.height
                            }
                        }
                    ]
                

                Would anchor changes be better?

                AnchorChanges {
                    target: rect
                    anchors.fill: <parentid>
                }
                
                JoeCFDJ Offline
                JoeCFDJ Offline
                JoeCFD
                wrote on last edited by JoeCFD
                #7

                @fcarney good idea. Will try it out. Thanks.

                1 Reply Last reply
                0
                • fcarneyF fcarney

                  @JoeCFD said in how to set fullscreen mode of a qml rectangle?:

                  Its parent is not the main window.

                  Then maybe you can try a parent change as well.

                  JoeCFDJ Offline
                  JoeCFDJ Offline
                  JoeCFD
                  wrote on last edited by JoeCFD
                  #8

                  @fcarney Tried this and no help. I will try to add a few more layers in my test case and may be able to find some clues.

                  1 Reply Last reply
                  0
                  • fcarneyF Offline
                    fcarneyF Offline
                    fcarney
                    wrote on last edited by
                    #9

                    Create a new test project. Add just enough code to recreate the problem there. Share that code.
                    That way we can see the problem and run it ourselves.

                    C++ is a perfectly valid school of magic.

                    1 Reply Last reply
                    0
                    • JoeCFDJ Offline
                      JoeCFDJ Offline
                      JoeCFD
                      wrote on last edited by
                      #10

                      Fixed by making state change at the top level rectangle.

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved