QWidget with QTabWidget
-
wrote on 5 Apr 2023, 21:39 last edited by
-
Hi all. Please tell me why when adding a tab widget, the main widget does not expand automatically?
l
wrote on 5 Apr 2023, 22:39 last edited by@ixion I may be wrong but as far as I know size policy works only for widgets put inside layout. The last line is a do nothing line as 'this' is not child of any layout (and it cannot be). Best thing to do I think is to set main widget size manually.
-
Hi all. Please tell me why when adding a tab widget, the main widget does not expand automatically?
l
-
@ixion
Add this method:QSize sizeHint() const override { return QSize(500,400); }
Or resize your widget after show():
widget.resize(500,400); -
@mpergand thanks, but I can't make the widget resize automatically depending on the objects inside it?
-
@ixion
Try:
tableWidget->resize(500,400);
If it doesn't work try to set a fixed or a minimum size instead.wrote on 5 Apr 2023, 23:02 last edited by@mpergand said in QWidget with QTabWidget:
ni
thanks, I know about resize, I'm interested in the automatic resizing of the widget, without explicitly specifying the size
-
@mpergand said in QWidget with QTabWidget:
ni
thanks, I know about resize, I'm interested in the automatic resizing of the widget, without explicitly specifying the size
wrote on 5 Apr 2023, 23:05 last edited by@ixion without being in a layout, as far as I know, there's nothing. I think you will have either to live with your main widget not risizing automatically, or implement that auto resize by yourself (by adding the width of all tabs + some constant should be what you need).
-
@mpergand said in QWidget with QTabWidget:
ni
thanks, I know about resize, I'm interested in the automatic resizing of the widget, without explicitly specifying the size
-
@ixion
I don't think it works with a tabWidget ...
What size is return by tabWidget->sizeHint() ? -
wrote on 5 Apr 2023, 23:16 last edited by
@ixion said in QWidget with QTabWidget:
@mpergand QSize(204, 32)
Seems close to the image you post.
In the Designer try with different size policies and see if it changes something. -
wrote on 6 Apr 2023, 04:41 last edited by
@ankou29666 said in QWidget with QTabWidget:
without being in a layout, as far as I know, there's nothing. I think you will have either to live with your main widget not risizing automatically, or implement that auto resize by yourself (by adding the width of all tabs + some constant should be what you need).
thanks
-
@ankou29666 said in QWidget with QTabWidget:
without being in a layout, as far as I know, there's nothing. I think you will have either to live with your main widget not risizing automatically, or implement that auto resize by yourself (by adding the width of all tabs + some constant should be what you need).
thanks
wrote on 6 Apr 2023, 11:34 last edited by mpergand 4 Jun 2023, 11:39 -
wrote on 6 Apr 2023, 12:45 last edited by JonB 4 Jun 2023, 12:45
@mpergand
I have only used Qt on Linux. My impression was that it never auto-grows a top-level window, at least when you put more content into it, i.e. like the left-hand one. Maybe it only does that window-widening under MacOS? -
@mpergand
I have only used Qt on Linux. My impression was that it never auto-grows a top-level window, at least when you put more content into it, i.e. like the left-hand one. Maybe it only does that window-widening under MacOS?wrote on 7 Apr 2023, 12:16 last edited by@JonB said in QWidget with QTabWidget:
I have only used Qt on Linux. My impression was that it never auto-grows a top-level window, at least when you put more content into it, i.e. like the left-hand one.
Since on linux, the length of the tab titles are not taken into account, the overall size of the tab widget reflects the widest element present in the tab pages.
On mac, the minimum size of the tab widget depends of the length of the tab titles.
Otherwise the tab titles are troncated with ellipsis, very ugly.
1/14