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. Positioning in qml is incomplete

Positioning in qml is incomplete

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
7 Posts 2 Posters 664 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.
  • A Offline
    A Offline
    AliPanahi2
    wrote on last edited by
    #1

    we can't create "Anchor Layout Example" in qml.
    two problems:

    • without layout dont exist minimum, preferred, maximum width and height.
    • with layout can't use anchors.
    1 Reply Last reply
    0
    • MarkkyboyM Offline
      MarkkyboyM Offline
      Markkyboy
      wrote on last edited by
      #2

      Are you saying you cannot make the example run?, it should work, provided you have used the correct data. If you use the resources from the following link (.pro, .cpp) https://code.qt.io/cgit/qt/qtbase.git/tree/examples/widgets/graphicsview/anchorlayout?h=5.14 it should just work.

      Perhaps I misunderstand your question . . . ?

      Don't just sit there standing around, pick up a shovel and sweep up!

      I live by the sea, not in it.

      A 1 Reply Last reply
      0
      • MarkkyboyM Markkyboy

        Are you saying you cannot make the example run?, it should work, provided you have used the correct data. If you use the resources from the following link (.pro, .cpp) https://code.qt.io/cgit/qt/qtbase.git/tree/examples/widgets/graphicsview/anchorlayout?h=5.14 it should just work.

        Perhaps I misunderstand your question . . . ?

        A Offline
        A Offline
        AliPanahi2
        wrote on last edited by
        #3

        @Markkyboy no, this example make and run correctly.
        can you write this example with qml to working like this?

        1 Reply Last reply
        0
        • MarkkyboyM Offline
          MarkkyboyM Offline
          Markkyboy
          wrote on last edited by
          #4

          Ahhh, I see, sorry, I knew I misunderstood. Okay, you want to reproduce the original but using QML.

          I will see what I can come up with, as I have several personal apps that use multiples of buttons.

          Don't just sit there standing around, pick up a shovel and sweep up!

          I live by the sea, not in it.

          1 Reply Last reply
          0
          • MarkkyboyM Offline
            MarkkyboyM Offline
            Markkyboy
            wrote on last edited by Markkyboy
            #5

            Okay, this is as close as I could get (but without anchoring methods);

            import QtQuick 2.12
            import QtQuick.Window 2.12
            import QtQuick.Layouts 1.3
            import QtQuick.Controls 1.4
            
            Window {
                visible: true
                width: 200; height: 120
                title: qsTr("Anchor layout in QML")
            
                GridLayout {
                    rows: 4
                    columns: 3
            
                    // row 1
                    Button {
                        text: "A"
                    }
                    Button {
                        text: "B"
                        Layout.fillWidth: true
                        Layout.columnSpan: 2
                    }
            
                    // row 2
                    Button {
                        text: "F"
                        Layout.row: 2
                        Layout.preferredWidth: 40
                    }
            
                    //row 3
                    Button {
                        text: "G"
                        Layout.row: 3
                        Layout.preferredWidth: 40
                    }
            
                    // row2
                    Button {
                        text: "C"
                        Layout.row: 2
                        Layout.rowSpan: 2
                        Layout.column: 1
                        Layout.fillHeight: true
                    }
            
                    // row 4
                    Button {
                        text: "D"
                        Layout.fillWidth: true
                        Layout.columnSpan: 2
                        Layout.row: 4
                    }
                    Button {
                        text: "E"
                        Layout.row: 4
                        Layout.column: 2
                    }
                }
            }
            
            

            Capture.JPG
            Capture1.JPG

            Don't just sit there standing around, pick up a shovel and sweep up!

            I live by the sea, not in it.

            A 1 Reply Last reply
            0
            • MarkkyboyM Markkyboy

              Okay, this is as close as I could get (but without anchoring methods);

              import QtQuick 2.12
              import QtQuick.Window 2.12
              import QtQuick.Layouts 1.3
              import QtQuick.Controls 1.4
              
              Window {
                  visible: true
                  width: 200; height: 120
                  title: qsTr("Anchor layout in QML")
              
                  GridLayout {
                      rows: 4
                      columns: 3
              
                      // row 1
                      Button {
                          text: "A"
                      }
                      Button {
                          text: "B"
                          Layout.fillWidth: true
                          Layout.columnSpan: 2
                      }
              
                      // row 2
                      Button {
                          text: "F"
                          Layout.row: 2
                          Layout.preferredWidth: 40
                      }
              
                      //row 3
                      Button {
                          text: "G"
                          Layout.row: 3
                          Layout.preferredWidth: 40
                      }
              
                      // row2
                      Button {
                          text: "C"
                          Layout.row: 2
                          Layout.rowSpan: 2
                          Layout.column: 1
                          Layout.fillHeight: true
                      }
              
                      // row 4
                      Button {
                          text: "D"
                          Layout.fillWidth: true
                          Layout.columnSpan: 2
                          Layout.row: 4
                      }
                      Button {
                          text: "E"
                          Layout.row: 4
                          Layout.column: 2
                      }
                  }
              }
              
              

              Capture.JPG
              Capture1.JPG

              A Offline
              A Offline
              AliPanahi2
              wrote on last edited by AliPanahi2
              #6

              @Markkyboy thanks.
              please change "Anchor Layout Example" form size and look at how the buttons size change.

              1 Reply Last reply
              0
              • MarkkyboyM Offline
                MarkkyboyM Offline
                Markkyboy
                wrote on last edited by
                #7

                Sorry, this is beyond my current capabilities. How far have you got with it?

                Don't just sit there standing around, pick up a shovel and sweep up!

                I live by the sea, not in it.

                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