Combining QTabWidget und QStackedWidget at runtime
-
Hi,
as some of the tabs of my QTabWidget instance will only be needed if certain conditions in a configuration file are met, I would like to be able to show a html page after a click on a QTableView cell in the optional tabs as well.
I got it to work with the help of the code generated by QtCreator, that I try to make use of for the optional tabs as well. But unfortunately nothing shows up in the corresponding tabs.
For the optional tab (I confined myself to one for testing) I did the following
baseWidget = new QWidget(); stackedWidget = new QStackedWidget(baseWidget); contentWidget = new QWidget(baseWidget); tview = new QTableView(contentWidget);
Finally I added the baseWidget to the QTabWidget instance and the contentWidget as well as Widget for the html to the QStackedwidget instance.
But, as I said, nothing is showing up, when I enter the corresponding tab.
What may be the cause of this behaviour?
Kind regards,
Andreas
-
Hi,
In fact you are just parenting widgets one to the other. That does not mean they will be shown.
You should simply build the widgets that should be shown in the stack, add them to your QStackedWidget and then add the stacked widget as new tab to your QTabWidget.
-
@andi456 depending on what you want to achieve, you should also check the layout management chapter. That will simplify things.
-