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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T14:35:16+00:00 2026-06-04T14:35:16+00:00

I have what is hopefully a simple problem using a QTableWidget in Qt Designer

  • 0

I have what is hopefully a simple problem using a QTableWidget in Qt Designer with Qt v4.7.1. I would like to create a dialog with a QTableWidget set to a 3×3 grid, then set the inititial size of the table to exactly show the 3×3 grid, without scrollbars. I don’t want the table to be any bigger or smaller than this. I then want to set the initial size of the dialog (it can be a fixed size) to the exact size required for this table.

I have gone through these steps in Qt Designer:

  1. Create a new dialog (for this example we’ll use a dialog without buttons).
  2. Drag in a QTableWidget.
  3. Double click on the table and set 3 rows (called 1, 2 and 3) and 3 columns (likewise) then hit OK.
    • The table is now the same size as the empty table when I initially dragged it in. This isn’t wide enough for three columns, so I have a horizontal scrollbar, and is too high for three rows so I have a lot of empty space at the bottom.
  4. Right-click on the dialog and select “Lay Out In A Grid” (or horizontally/vertically).
    • The table now resizes to fill the dialog which is larger than required, so I can see all rows/columns but there’s lots of empty space on the right & bottom.
  5. Right-click on the dialog and say “Adjust Size”.
    • The table now jumps back to the initial size, ie. not wide enough so with a horizontal scroll bar, and too high. The dialog is resized to fit this table.

The dialog resizing to fit the table is correct. But how can I resize the table to fit it’s contents?

I have tried lots of other things, eg. changing the size policy on the table to “fixed,fixed” or “minimum,minimum” but it still wants to set the initial size to a size that doesn’t match the contents. Ideally I would like the table/dialog to set only the correct initial size and allow the user to make the dialog smaller (which would add scrollbars) but it’s not the end of the world if I have to make the size fixed.

Is it possible to do this in Qt Designer or should I be setting the size in code?

Thanks a lot for any replies.

  • 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-04T14:35:18+00:00Added an answer on June 4, 2026 at 2:35 pm

    Note that unless the QTableWidget doesn’t force any size, neither does your QDialog. So what you need is to fix the size of the QTableWidget; the QDialog doesn’t have anything to do with this. The layout then will try to resize the QDialog when the QTableWidget wants to force another size.

    But setting the size of a QTableWidget to a specific count of rows/cols isn’t possible as far as I know, at least not from within QtDesigner.

    You need to write a bit of code to achieve this. The code needs to request the widths of the columns and the heights of the rows (including headers), and add the borders of the widget. Then set this size using ui->tableWidget->setFixedSize(...). You would then also need to react on resizing of the columns / rows, if you enable this for the user.


    For fixed cell size and invisible headers, there is a possible solution with no manual code (fully in QtDesigner):

    • Set (horizontal|vertical)HeaderVisible = false
    • Set (horizontal|vertical)HeaderDefaultSectionSize = (fixedValue)
    • Set (horizontal|vertical)HeaderMinimumSectionSize = (fixedValue)
    • Set the size of the QTableWidget to the sum of the sizes. Remember to add (column count + 1) and (row count + 1) pixels to your fixed total size of the QTableWidget.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is hopefully a simple question: I have an OpenGL texture and would like
Hopefully a simple question although one I have found impossible to answer myself using
Ok, simple problem hopefully. I have started to make a simple server for a
I have a (hopefully quite simple) Javascript problem. I've search but found nothing that
I have what is a simple problem that hopefully has a simple solution: I
I have a problem that hopefully has a simple solution. I am trying to
I'm just getting started with Require.JS and I have a (hopefully) simple question. I'm
Hopefully this is simple: I have a relatively long list where each list item
hopefully a pretty simple question this time. I have a Select method in a
Hopefully I am overlooking a something simple. I have tablix control with a table

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.