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

  • Home
  • SEARCH
  • 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 8411669
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:28:47+00:00 2026-06-10T00:28:47+00:00

I want to create a Qt window that contains two layouts, one fixed height

  • 0

I want to create a Qt window that contains two layouts, one fixed height that contains a list of buttons at the top and one that fills the remaning space with a layout that centers a widget vertically and horizontally as per the image below.

Example Qt layout

How should i be laying out my layouts/widgets. Ive tried a few options with nested horizontal and vertical layouts to no avail

  • 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-10T00:28:48+00:00Added an answer on June 10, 2026 at 12:28 am

    Try making the pink box a QWidget with a QHBoxLayout (rather than just making it a layout). The reason is that QLayouts don’t provide functionality to make fixed sizes, but QWidgets do.

    // first create the four widgets at the top left,
    // and use QWidget::setFixedWidth() on each of them.
    
    // then set up the top widget (composed of the four smaller widgets):
    QWidget *topWidget = new QWidget;
    QHBoxLayout *topWidgetLayout = new QHBoxLayout(topWidget);
    topWidgetLayout->addWidget(widget1);
    topWidgetLayout->addWidget(widget2);
    topWidgetLayout->addWidget(widget3);
    topWidgetLayout->addWidget(widget4);
    topWidgetLayout->addStretch(1); // add the stretch
    topWidget->setFixedHeight(50);
    
    // now put the bottom (centered) widget into its own QHBoxLayout
    QHBoxLayout *hLayout = new QHBoxLayout;
    hLayout->addStretch(1);
    hLayout->addWidget(bottomWidget);
    hLayout->addStretch(1);
    bottomWidget->setFixedSize(QSize(50, 50));
    
    // now use a QVBoxLayout to lay everything out
    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addWidget(topWidget);
    mainLayout->addStretch(1);
    mainLayout->addLayout(hLayout);
    mainLayout->addStretch(1);
    

    If you really want to have two separate layouts–one for the pink box and one for the blue box–the idea is basically the same except you’d make the blue box into its own QVBoxLayout, and then use:

    mainLayout->addWidget(topWidget);
    mainLayout->addLayout(bottomLayout);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my Android app I want to create a dialog window that contains an
I want to create a separate thread that runs its own window. Frankly, the
I want to create a companion Windows desktop program for my app. One that
I want to create a web page that contains an (Flex/Flash) audio player that
Hi I am trying to create a one page website that contains multiple div's
I want to create applications in windows that has complete portability (within windows OSes
I want to create a powershell script that creates a shortcut in the windows
I want to create a program that runs on iPads, Playbooks, and Windows computers
I want to create a tabbed window. with 3 tabs, Blue , Green and
I want to create and display a self designed window on current webpage instead

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.