How can i get pointer on the widget of current tab in QTabWidget?
-
A bit hard to see what's wrong from just those four lines of code.
I assume qssTextEdit is a QPlainTextEdit subclass?
And that you haven't added any other tabs?
You could always check what tabWidget->currentWidget() actually returns, using a debugger or some form of debug output, e.g. by printing what tabWidget->currentWidget()->metaObject()->className() returns. -
To read the text associated with a tab's QTextEdit widget ( tab at index x) , I did this
@ tabWidget->addTab(new QTextEdit ,"New tab");
QTextEdit* t= qobject_cast<QTextEdit*>(tabWidget->widget(x));
qDebug() << t->toPlainText();
@Just in case someone still needed it.
-
Hi.. Ruzik
once try this code..
QTabWidget *wd;
tabWidget->addTab(new QTextEdit ,"New tab");QList<QTextEdit * > widgets = wd->findChildren<QTextEdit* >();
.....widgets.at(2) or widgets.at(index)