What happens to widgets added to QTabWidget?
-
Hi,
I had lots of widgets in a stacked layout and wanted to group some of them in a
QTabWidget
but something very strange happens:This is the page in stacked layout:
and this is the same widget (unchanged!) added to a QTabWidget.
Font and colors are read fromQSettings
and applied byQLabel::setStyleSheet(...)
Every button is connected to functions that will raise a dialog to change color/font - but when the widget is part of QTabWidget, no button works.
some code excerpts - first the stacked page:
page = new PreferencesEditor(":/src/UI/Settings.ui", mainView); mainView->addPage(page); ui->menuMain->addAction(page->viewAction()); SettingsNotebook* nb = new SettingsNotebook(this); nb->addPage(new ToolManager(conn, nb)); nb->addPage(new FixtureManager(Core().axisMask(), nb)); // nb->addPage(new PreferencesEditor(":/src/UI/Settings.ui", nb)); mainView->addPage(nb); ui->menuMain->addAction(nb->viewAction());
... and here the tabbed page:
// page = new PreferencesEditor(":/src/UI/Settings.ui", mainView); // mainView->addPage(page); // ui->menuMain->addAction(page->viewAction()); SettingsNotebook* nb = new SettingsNotebook(this); nb->addPage(new ToolManager(conn, nb)); nb->addPage(new FixtureManager(Core().axisMask(), nb)); nb->addPage(new PreferencesEditor(":/src/UI/Settings.ui", nb)); mainView->addPage(nb); ui->menuMain->addAction(nb->viewAction());
addPage
is just a wrapper around addTab which uses the objectName as Name for the tab. -
You set a stylesheet to your QTabWidget which is also applied to the children. Fix your stylesheet so it's only applied to your QTabWidget.
-
Hi,
maybe I don't understand you.
At the moment I don't care for the QTabWidget at all.
The page with the buttons and labels is a separate class and this class applies stylesheets to the labels.beside the stylesheet issue - I don't understand, why the button connections don't work any more.
I added another widget, which is a master/detail widget with QTreeView and QTableView - there the model/view connection don't work when the widget is added to the QTabWidget.
I guess I have a big misunderstanding of QTabWidget.
-
Hi,
I had lots of widgets in a stacked layout and wanted to group some of them in a
QTabWidget
but something very strange happens:This is the page in stacked layout:
and this is the same widget (unchanged!) added to a QTabWidget.
Font and colors are read fromQSettings
and applied byQLabel::setStyleSheet(...)
Every button is connected to functions that will raise a dialog to change color/font - but when the widget is part of QTabWidget, no button works.
some code excerpts - first the stacked page:
page = new PreferencesEditor(":/src/UI/Settings.ui", mainView); mainView->addPage(page); ui->menuMain->addAction(page->viewAction()); SettingsNotebook* nb = new SettingsNotebook(this); nb->addPage(new ToolManager(conn, nb)); nb->addPage(new FixtureManager(Core().axisMask(), nb)); // nb->addPage(new PreferencesEditor(":/src/UI/Settings.ui", nb)); mainView->addPage(nb); ui->menuMain->addAction(nb->viewAction());
... and here the tabbed page:
// page = new PreferencesEditor(":/src/UI/Settings.ui", mainView); // mainView->addPage(page); // ui->menuMain->addAction(page->viewAction()); SettingsNotebook* nb = new SettingsNotebook(this); nb->addPage(new ToolManager(conn, nb)); nb->addPage(new FixtureManager(Core().axisMask(), nb)); nb->addPage(new PreferencesEditor(":/src/UI/Settings.ui", nb)); mainView->addPage(nb); ui->menuMain->addAction(nb->viewAction());
addPage
is just a wrapper around addTab which uses the objectName as Name for the tab.@django-Reinhard said in What happens to widgets added to QTabWidget?:
Every button is connected to functions that will raise a dialog to change color/font - but when the widget is part of QTabWidget, no button works.
Where do you do any of these
connect()
s? -
Hi,
thank you for your attention and support!
You're a real professional!
The right question.It took me a while to get it, but - of cause - you where right.
I'm getting old.
I forgot the second purpose of DynWidget ancestors - late initialization. So it was a typical PEBCAK.