Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8102283
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T23:12:19+00:00 2026-06-05T23:12:19+00:00

I have a container widget with a QVBoxLayout. I have about 100 widgets added

  • 0

I have a container widget with a QVBoxLayout.

I have about 100 widgets added into the VBoxLayout. They all have the same height.
At some point there’s a need to resize one of the rows. I resize(newWidth, newHeight) the widget and call layout() on the QVBoxLayout, but nothing changes. the size remains fixed.

How do I dynamically change the height of widgets in QVBoxLayout?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T23:12:21+00:00Added an answer on June 5, 2026 at 11:12 pm

    A resize of a widget that is inserted in a layout is a no-op, by design. The layout sizes the widgets, not you.

    If you want a fixed-height widget in a QVBoxLayout, you have to set the widget’s minimum and maximum height, and ensure its sizePolicy is not ignored in vertical direction.

    If you want a widget that’s twice the height of all other widgets. Set its stretch to 2, and stretch of other widgets to 1. Call layout->setStretch(index, stretch). The widgets will be assigned width proportionally to their stretches. For example, with all stretches at 1 and one stretch at 2, the widget with stretch 2 will get twice the room.

    Everything else being equal (that’s the important bit!), stretches are proportional to pixel sizes of widgets. If you want, say all widgets to be 20 pixels tall, but one to be 30 pixels tall, just set their stretches like so.

    If the layout has the exact height so that the sum of all widget heights + spacings + margins adds up to layout height, you’ll get height=stretch for widgets in the layout. Conversely, if you start with layout height, subtract the top and bottom margins and (widget count – 1)*spacing, you’ll have height left for the widgets. You can then manually distribute that height among the widgets by setting stretch equal to desired height.

    You may need to override the sizePolicy of the widgets, if they are too big by default.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a ScrollArea, containing a VBoxLayout containing several Labels: realmScroll = QScrollArea(self.container.widget()) realmScroll.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
I have a container class which I would like to use to print all
for example lets say i have the html <div id=container> <div id=js-widget> <script srcxxxyyyzzz
I have a widget which I'm putting in a QVBoxLayout. This widget's layout is
I'm into a problem with a GTK+ C application. I have a container that,
Mornin' all, I have troubles to play with jQuery UI autocomplete widget events. I
As far as I can tell, all GUI toolkits are basically the same. They
hey guys, i did the following function in order to have the same height
I currently have a div container for all of the input fields in my
I am having problems while adding my widget into the RootPanel of another container

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.