Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get all tabs widgets in QTabWidget

Tags:

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.

like image 535
Qiao Avatar asked May 29 '11 10:05

Qiao


People also ask

How do I use tab widget in Qt?

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.

How do I add a tab in PyQt?

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.")

How do I change my Qt tab name?

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.

How do I create a tab in Qt?

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 ...


1 Answers

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.

like image 64
Mat Avatar answered Sep 17 '22 02:09

Mat