I know I can use the widget function of QTabWidget in order to get the the QPlanTextEdit from the specified tab. But how can I get the tab title text of the current tab widget?
QPlainTextEdit* pTextEdit = NULL;
QWidget* pWidget= ui->tabWidget->widget(1);
if (pWidget->metaObject()->className() == "QPlainTextEdit")
pTextEdit = (QPlainTextEdit*)pWidget;
else
{
QList<QPlainTextEdit *> allTextEdits = pWidget->findChildren<QPlainTextEdit *>();
if (allTextEdits.count() != 1)
{
qError() << "Error";
return;
}
pTextEdit = allTextEdits[0];
}
ptextEdit->setPlainText("Updated Plain Text Edit);
// HERE I NEED THE CURRENT TAB'S TEXT!!
If so, click on the tab you want to rename, then in the Property Editor (if you can't find it make sure it's visible by using the View->Property Editor menu item) scroll down to the bottom and look for the currentTabText property. You can change the tab's name right there.
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.
The QWidget class is the base class of all user interface objects. The widget is the atom of the user interface: it receives mouse, keyboard and other events from the window system, and paints a representation of itself on the screen. Every widget is rectangular, and they are sorted in a Z-order.
int index = ui->tabWidget->currentIndex();
QString currentTabText = ui->tabWidget->tabText(index);
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