Is it possible to get all tabs widgets that where added by addTab(QWidget()
in QTabWidget in a list.
We can use self.findChildren(QWidget)
, but it also returns all other widgets inside itself, and there is no way to filter them.
The normal way to use QTabWidget is to do the following: Create a QTabWidget. Create a QWidget for each of the pages in the tab dialog, but do not specify parent widgets for them. Insert child widgets into the page widget, using layouts to position them as normal.
PyQt tabs example To add a tab to a QTabWidget , call the method . addTab() . label1 = QLabel("Widget in Tab 1.") label2 = QLabel("Widget in Tab 2.")
Select the parent QTabWidget in Object Inspector. First select the "currentIndex" corresponding to the tab you would like to alter and hit enter. Change the name using the currentTabText property. Continue doing this for all indexes 0-n.
TabDialog::TabDialog(const QString &fileName, QWidget *parent) : QDialog(parent) { QFileInfo fileInfo(fileName); tabWidget = new QTabWidget; tabWidget->addTab(new GeneralTab(fileInfo), tr("General")); tabWidget->addTab(new PermissionsTab(fileInfo), tr("Permissions")); tabWidget->addTab(new ApplicationsTab(fileInfo), tr ...
Read the documentation you pointed to more carefully :-)
QTabWidget
has a QWidget *widget(int index)
method that returns the tab at index index
. Use that to get the tab widgets. That class also has a int count();
that tells you how many tabs there are.
With these two, you can iterate over all the tabs quite easily.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With