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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:17:37+00:00 2026-06-11T16:17:37+00:00

I am writing a program with Qt that looks like this: The main window

  • 0

I am writing a program with Qt that looks like this:

screen capture

The main window is a class Window : QWidget that I have defined. It has a QGridLayout which basically has 1 row and 3 columns. As you can see, the first column contains a menu (which is a class Menu :QWidget), the second and third columns each contain a canvas (a class Canvas : QWidget that I have also defined).

I am having a really hard time trying to figure out how the sizes work. So far, I have just defined a minimum size for the first column’s width (in my window’s layout) to fix the menu’s width, and I have set a fixed size for Canvas in its constructor (like this: setFixedSize(QSize(size_in_pixels, size_in_pixels));).

The problem is of course that this behaves badly under rescaling the window by the user. I guess what I would like to do is sort of set my canvas’s sizeHint to size_in_pixels (my preferred size) but this hardly seems possible. I would also like my canvases to have same height and width at all times. I have been reading Qt documentation and trying several things but I can’t come up with a solution.

What would be the way to go according to you? Thanks a lot for your insights.

  • 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-11T16:17:39+00:00Added an answer on June 11, 2026 at 4:17 pm

    You can just set the canvas widgets to an Expanding size policy. They will equally consume the remaining space as the layout increases in size.

    Here is an example, written in PyQt4

    widget = QtGui.QWidget()
    widget.resize(800,600)
    layout = QtGui.QGridLayout(widget)
    
    label = QtGui.QLabel("Menu")
    label.setFrameStyle(label.Box)
    label.setMinimumWidth(100)
    layout.addWidget(label, 0, 0)
    
    label = QtGui.QLabel("Canvas 1")
    label.setFrameStyle(label.Box)
    policy = QtGui.QSizePolicy(
        QtGui.QSizePolicy.Expanding, 
        QtGui.QSizePolicy.Expanding)
    label.setSizePolicy(policy)
    layout.addWidget(label, 0, 1)
    
    label = QtGui.QLabel("Canvas 2")
    label.setFrameStyle(label.Box)
    layout.addWidget(label, 0, 2)
    policy = QtGui.QSizePolicy(
        QtGui.QSizePolicy.Expanding, 
        QtGui.QSizePolicy.Expanding)
    label.setSizePolicy(policy)
    

    small

    larger

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

Sidebar

Related Questions

I am writing a program in Qt that looks like this: The main window
I'm writing a program that uses an Event class, which has in it an
I am writing a maze game program that looks like this: import java.util.*; import
Im writing a program that should read input via stdin, so I have the
I'm writing a program that sits in the systray. It will have a keyboard
I have a simple Linux C program that I'm writing to help me better
I'm writing a program that handles DBs and writes any changes into ListView for
I'm writing a program that's parsing an XML file to java objects using smooks.
I'm writing a program that reads huge file (3x280 GB) and does a fitting
I am writing a program that permutes a list of names based on a

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.