Qt中如何获取QWidget的QTabWidget标题文本?
How to get QTabWidget title text of QWidget in Qt?
我知道我可以使用 QTabWidget 的小部件功能从指定的选项卡中获取 QPlanTextEdit。但是如何获取当前标签小部件的标签标题文本?
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!!
int index = ui->tabWidget->currentIndex();
QString currentTabText = ui->tabWidget->tabText(index);
我知道我可以使用 QTabWidget 的小部件功能从指定的选项卡中获取 QPlanTextEdit。但是如何获取当前标签小部件的标签标题文本?
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!!
int index = ui->tabWidget->currentIndex();
QString currentTabText = ui->tabWidget->tabText(index);