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. [SOLVED] QGridLayout: different % widths
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] QGridLayout: different % widths

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.1k 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.
  • S Offline
    S Offline
    secondVISION
    wrote on last edited by
    #1

    Hey, I currently have a qgridlayout like:

    Row 1: QHBoxLayout( Widget - Widget - Widget )
    Row 2: QHBoxLayout( Widget - Widget - Widget )
    Row 3: QHBoxLayout( Widget - Widget - QVBoxLayout(QLabel - QLCDNumber))

    Now all these layouts and the widgets inside them have the same size.
    So for row 1: 33.33% / 33.33% / 33.33%
    What I would like: 25% / 50% / 25% for all rows.

    Is this possible?

    Thank you!

    edit:
    I tried doing this with the middle widget:
    middleWidgetRow1->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Ignored);
    This gets me : 1% / 98% / 1%.

    edit: Got it working with horizontal stretch!

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

      Hi,

      You should get what you want using the stretch factor:
      @
      hBoxLayout->addWidget(widget1, 1);
      hBoxLayout->addWidget(widget2, 2);
      hBoxLayout->addWidget(widget3, 1);
      @

      Hope it helps

      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
      0
      • S Offline
        S Offline
        secondVISION
        wrote on last edited by
        #3

        Ha, that's a smaller solution than the one I'm using. Thanks for that!

        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