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. [SOLVED]resizing window doesn't resize gui element
Forum Updated to NodeBB v4.3 + New Features

[SOLVED]resizing window doesn't resize gui element

Scheduled Pinned Locked Moved QML and Qt Quick
10 Posts 2 Posters 4.0k 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
    av2306
    wrote on last edited by
    #1

    Hi,

    Have a component and loading through element. When I resize window, it's not increasing width as per parent window. How to handle this? Should I handle onWidthChanged property?

    @Component {
        id: testui
        Rectangle {
            width: 500
            height: 500
            color: "red"
        }
    }
    
    Loader {
            sourceComponent:testui
            anchors.top: anothercontrol.bottom
            width: parent.width
    }@
    

    Thanks.

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dasRicardo
      wrote on last edited by
      #2

      Hmmmm, your source is wrong or not complete so it's a little bit complicated to understand what you want. But if you want that your Loader change it's width when you resize it's parent you need to use anchors.

      @
      ApplicationWindow {
      width: 640
      height: 480
      Rectangle {
      anchors.fill: parent //to fill the entire AppWindow
      Loader {
      id: toolBar
      // You can set the properties here or in the file did the same
      anchors.left: parent.left
      anchors.right: parent.right
      height: 35
      source: Qt.resolvedUrl("File.qml")
      }
      Rectangle {
      anchors.top: toolBar.bottom
      anchors.bottom: parent.bottom
      anchors.left: parent.left
      anchors.right: parent.right
      color: #ffff00
      }
      }
      }
      @

      **Sorry for my english :)

      PLEASE ADD [SOLVED] TO YOUR THREAD TITLE IF IT'S SOLVED.**

      1 Reply Last reply
      0
      • A Offline
        A Offline
        av2306
        wrote on last edited by
        #3

        I can't see left and right properties for toolbar. I am using component.

        when I maximize window, it will show rectangle for 640 * 50. Not maximizing as per parent window. How to do that?

        working code:

        @ApplicationWindow {
        width: 640
        height: 480

        Item {
            Loader {
                id: testloader
                anchors.top: parent.top
                sourceComponent: rect
            }
        
            Component {
                id: rect
                Rectangle {
                    width: 640
                    height: 50
                    color: "red"
                   anchors.left: parent.left//error
                   anchors.right: parent.right//error
                }
            }
        }
        

        }@

        1 Reply Last reply
        0
        • D Offline
          D Offline
          dasRicardo
          wrote on last edited by
          #4

          First problem:
          Take a look: "HERE...":http://qt-project.org/doc/qt-5/qml-qtqml-component.html
          Because Component is not derived from Item, you cannot anchor anything to it

          Second problem:
          You can not set width and anchors.left/anchors.right only one of them.

          Sorry but can you explain me what you want to do, why the loader? Why the component? I did an update of my example so maybe its right for you now.

          **Sorry for my english :)

          PLEASE ADD [SOLVED] TO YOUR THREAD TITLE IF IT'S SOLVED.**

          1 Reply Last reply
          0
          • A Offline
            A Offline
            av2306
            wrote on last edited by
            #5

            dasRicardo, your code snippet works fine. I don't have any doubt.

            In run time, i need to replace ui elements. for example, instead of red toolbar, want to display textedit control/customized control in run time. How to do that?

            1 Reply Last reply
            0
            • D Offline
              D Offline
              dasRicardo
              wrote on last edited by
              #6

              OK, yeah for this you can use Loader, i tried another update, i'm not at home so no guaranty :)

              **Sorry for my english :)

              PLEASE ADD [SOLVED] TO YOUR THREAD TITLE IF IT'S SOLVED.**

              1 Reply Last reply
              0
              • A Offline
                A Offline
                av2306
                wrote on last edited by
                #7

                Solved by adjusting width. Thanks.

                1 Reply Last reply
                0
                • D Offline
                  D Offline
                  dasRicardo
                  wrote on last edited by
                  #8

                  so please mark all your solved threads as solved

                  **Sorry for my english :)

                  PLEASE ADD [SOLVED] TO YOUR THREAD TITLE IF IT'S SOLVED.**

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    av2306
                    wrote on last edited by
                    #9

                    'Where is the option to mark as solved. Plz dont mind.

                    1 Reply Last reply
                    0
                    • D Offline
                      D Offline
                      dasRicardo
                      wrote on last edited by
                      #10

                      Simply change the thread title like all the other solved threads here :)

                      **Sorry for my english :)

                      PLEASE ADD [SOLVED] TO YOUR THREAD TITLE IF IT'S SOLVED.**

                      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