Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Adjusting size between 2 widgets within a gridlayout (beginner question)
QtWS25 Last Chance

Adjusting size between 2 widgets within a gridlayout (beginner question)

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 6.3k Views
  • 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.
  • O Offline
    O Offline
    odonnemr
    wrote on 24 Jun 2011, 13:46 last edited by
    #1

    I have 2 widgets within a QGridLayout that are touching each other. Each of them take up half of the layout by default, but the user can't adjust the size between them. What I mean is, I'd like the user to be able to drag the separator between the two widgets and adjust the size, so that one size gets bigger and the other gets smaller. I've looked through the docs for a function that allows you to do this with no luck. Any ideas?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      soroush
      wrote on 24 Jun 2011, 13:57 last edited by
      #2

      Try QSplitter instead of QGridLayout.

      1 Reply Last reply
      0
      • C Offline
        C Offline
        Chuck Gao
        wrote on 24 Jun 2011, 14:09 last edited by
        #3

        Hi odonnemr,
        When i begin to use Qt, i also have this question before :D
        The answer is:

        1. QGridLayout will handle the position and the size of it's child widget(which in the layout). 2) Basiclly, the position can not be change, but we also have workaround solution. And for size, it can be change, you can have a look at the sizePolicy of the QWidget, but for your requirement, i think we'd better use the workaround.
          a. Use QML to write UI, it's more convenient for UI
          b. Write a container wrapper, which make your widget embeded, and set the container wrapper to the QGridLayout. And do adjust size as usual

        Chuck

        1 Reply Last reply
        0
        • O Offline
          O Offline
          odonnemr
          wrote on 24 Jun 2011, 14:31 last edited by
          #4

          what kind of container would you recommend chuck?

          1 Reply Last reply
          0
          • C Offline
            C Offline
            Chuck Gao
            wrote on 24 Jun 2011, 14:47 last edited by
            #5

            QWidget based is ok. Set the container to the layout, and handle the size change inside the container.

            Chuck

            1 Reply Last reply
            0
            • O Offline
              O Offline
              odonnemr
              wrote on 24 Jun 2011, 16:11 last edited by
              #6

              Thanks for your help guys, QSplitter did the trick

              1 Reply Last reply
              0

              4/6

              24 Jun 2011, 14:31

              • Login

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