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 8037509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:57:02+00:00 2026-06-05T02:57:02+00:00

I’m developing a little game in C++ Qt 4.6.3 and I stumbled upon a

  • 0

I’m developing a little game in C++ Qt 4.6.3 and I stumbled upon a layout-issue.
The layout I’m looking for is a 3×3 QGridLayout of which the central cell (1,1) holds the main widget (it’s a board game). The (0,1)-cell should hold a QLabel displaying whos turn it is, the (1,0) and (1,2) cells are subdivided into QVBoxLayouts to hold a maximum of 3 scoreboards, and the (2,1)-cell also holds some kind of QLabel.

Image of the layout

This is what I’ve got so far:

QGridLayout *mainLayout = new QGridLayout(this);
QVBoxLayout *leftLayout = new QVBoxLayout;
QVBoxLayout *rightLayout = new QVBoxLayout;  
mainLayout->addLayout(leftLayout,   1, 0, AlignTop);
mainLayout->addWidget(topText,      0, 1, AlignCenter);
mainLayout->addWidget(board,        1, 1);
mainLayout->addLayout(bottomText,   2, 1, AlignCenter);
mainLayout->addLayout(rightLayout,  1, 2, AlignTop);

Now, on MS Windows (laptop of my GF) I solved this by reimplementing the resizeEvent() function:

void Game::resizeEvent(QResizeEvent *)
{
    mainLayout->setRowMinimumHeight(1, 0.8 * height());
    mainLayout->setColMinimumWidth(1, 0.8 * height());
    // some other stuff
}

This worked fine! However, on Unix there seems to be a problem (or could it be due to a version difference? 4.6 vs 4.8). On calling the setRowMininmumHeight() method, it seems that another resize-event is issued, resulting in a recursive call! I want my application to work on both platforms, so clearly I had to find another solution. I fiddled around with setRowStretch() and setColStretch() but neither of those had the desired result. I tried all sorts of combinations but now I am quite stuck…

Does anyone have a solution to this seemingly easy problem?

  • 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-05T02:57:06+00:00Added an answer on June 5, 2026 at 2:57 am

    You should use stretches rather than minimum sizes to solve the problem. Execute this code after adding the widgets to the layout to assign 80% of the height to the middle row:

    mainLayout->setRowStretch(0, 1); // 10% for top row
    mainLayout->setRowStretch(1, 8); // 80% for middle row
    mainLayout->setRowStretch(2, 1); // 10% for bottom row
    

    Note that minimum size constraints of the contained widgets are still respected (unless you set the size policy to ignored). So if you want to assign the whole height minus the two minimum sizes of the rows 0 and 2 (as you are saying they should be “as small as possible”), assign 100% to the middle row and 0% to the rows 0 and 2; they still respect the minimum sizes:

    mainLayout->setRowMinimumHeight(0, 20); // 20px for top row
    mainLayout->setRowMinimumHeight(2, 20); // 20px for bottom row
    mainLayout->setRowStretch(0, 0);
    mainLayout->setRowStretch(1, 1); // remaining height for middle row
    mainLayout->setRowStretch(2, 0);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

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.