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. Problem with managing size of the widgets, layouts etc.

Problem with managing size of the widgets, layouts etc.

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 399 Views 2 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.
  • M Offline
    M Offline
    mimickxd
    wrote on last edited by
    #1

    Hi,
    I have a problem, that is probably easy to solve but somehow I'm lacking positive results. I don't use UI, this is a QWidget and windows 10 with mingw64.

    My program has a following structure:

    1. horizontal layout:
      11. vertical layout
      111. 2 buttons + e.g. spacer
      12. vertical layout:
      121. tableview object
      122. horizontal layout
      1221. 2 buttons

    When I use mouse to resize window, it resizes normally but 111 buttons move accordingly to the height of the window. What I want is that thos buttons stay in their place and ONLY spacer is resizing (imagine a columne, where vert_space_field1=button1, vert_space_field2=butt2, vert_space_field3=spacer and when resizing vertically, only vert_space_field3 resizes).

    Thanks for your help :)!

    Gojir4G 1 Reply Last reply
    0
    • M mimickxd

      Hi,
      I have a problem, that is probably easy to solve but somehow I'm lacking positive results. I don't use UI, this is a QWidget and windows 10 with mingw64.

      My program has a following structure:

      1. horizontal layout:
        11. vertical layout
        111. 2 buttons + e.g. spacer
        12. vertical layout:
        121. tableview object
        122. horizontal layout
        1221. 2 buttons

      When I use mouse to resize window, it resizes normally but 111 buttons move accordingly to the height of the window. What I want is that thos buttons stay in their place and ONLY spacer is resizing (imagine a columne, where vert_space_field1=button1, vert_space_field2=butt2, vert_space_field3=spacer and when resizing vertically, only vert_space_field3 resizes).

      Thanks for your help :)!

      Gojir4G Offline
      Gojir4G Offline
      Gojir4
      wrote on last edited by
      #2

      @mimickxd Hi, Can you show your code ? How do you add your "spacer" ?

      This should do the job:

      vLayout11->addWidget(bt1);
      vLayout11->addWidget(bt2);
      vLayout11->addStretch();
      
      1 Reply Last reply
      1
      • M Offline
        M Offline
        mimickxd
        wrote on last edited by
        #3

        You are actually correct, sir, it works.

        Thank you very much but can you actually explain why does it work?
        I mean, I already read doc. about streching and spacing but couldn't figure that one out :).

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi and welcome to devnet,

          The stretch is a spacer item that will expand as much as possible with respect to the other widgets in the same layout. If you want to ensure it takes all the place it can, then you should pass a bigger stretch factor than the other widgets in the layout.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          1

          • Login

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