Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Adjust dialog size to size of data in child QTableView works for width but not height
Qt 6.12 LTS is out! See what's new in the release blog

Adjust dialog size to size of data in child QTableView works for width but not height

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 384 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Offline
    O Offline
    olowo726
    wrote on last edited by olowo726
    #1

    I have a dialog with the following object hiearchy

    QDialog layout QVBoxLayout
       QWidget layout QHBoxLayout
           QTableViewItem
      QPushButton
    

    Hence fairly simple. The table view shall display a matrix. The size of this matrix may vary. Hence I wish to adjust the the size of the dialog to the data. This I've done by inserting

    resize(1,1);
    setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    

    in the dialog constructor. This works fine for width but the dialog height only becomes enough for a single row. I've tested different layouts and scrutinized all size proprties of the table view and the first child widget. They are the same for both horizontal and vertical and I've tested with both "preferred" and "expanding". Scrollbar settings for the tableview are the same for both horizontal and vertical. Header settings too. But still the dialog doesn't adjust height to number of rows in table.

    Why does width and height behaves differently and how can I get the dialog to the right height?

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt
    • Unsolved