Reputation: 3659
In my Qt program, I programmatically generate a modal QDialog. I want to show two widgets in this dialog window: A custom widget showing a camera output and a QTableWidget, showing the pixel coordinates of the corners found in the camera image. I generate a QHBoxLayout and add my custom widget and the QTableWidget into it. Then I set this QHBoxLayout as the Layout of the QDialog window. What I want to achieve is to share the available space in the QDialog's window area equally between my custom QWidget and the QTableWidget, horizontally, by using a QHBoxLayout. But I always end up with QTableWidget occupying the whole QDialog area, by overlapping my custom widget. How can I instruct these two widgets to exactly share the QDialog area?? Note that I first add my custom widget and then the QTableWidget into the QHBoxLayout.
Upvotes: 0
Views: 293
Reputation: 11764
Make sure on your custom widget you've specified a minimumSizeHint
and a sizeHint
, this instructs the QLayout
manager that the widget requires a specific space. To have them split equally you'll be best off detecting the size of the QDialog
and then specifying the width for both by removing the boundary sizes (spacing between widgets + space to QDialog
edge) and dividing it up.
Upvotes: 1