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. Making child widget fill region in QGridLayout
Forum Update on Monday, May 27th 2025

Making child widget fill region in QGridLayout

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

    I am using Qt 5.9.0 on Windows 10 x64. I am using a QGridLayout to layout QWidgets, the layout will look like this:
    0_1503912182941_layout.png

    So, I add 4 widgets to first column, changing only rows. After that, for the second column, I do a

    layout->setColumnStretch(0, 1); layout->setColumnStretch(1, 7); layout->addWidget(widget, 0, 1, 4, 1, Qt::AlignTop | Qt::AlignLeft)

    However, the widget in the second column does not expand and fill the region, it remains small (does not fill in either direction).
    I have tried setting the size policy to MinimumExpanding, but that does not do anything. How do I make widget fill the area ?

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      Can u give the sample program to check this ? It helps to fix your issue & give back.

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

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

        I have solved the issue. The trick was not to align in the direction in which I want it to expand. Since, I wanted it to fill parent both horizontally and vertically, so I removed the alignment flags while adding the widget.

        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