How can i get pointer on the widget of current tab in QTabWidget?
-
wrote on 16 Jun 2011, 18:55 last edited by
How can i get pointer on the widget of current tab in QTabWidget?
Advance many thanks fro help! -
wrote on 16 Jun 2011, 19:12 last edited by
"QTabWidget::currentWidget()":http://doc.qt.nokia.com/latest/qtabwidget.html#currentWidget
-
wrote on 16 Jun 2011, 19:14 last edited by
"Wow do you read the doc??..":http://doc.qt.nokia.com/4.7-snapshot/qtabwidget.html#currentWidget
-
wrote on 16 Jun 2011, 19:31 last edited by
I read it before i asked, but on the this code
@ tabWidget->addTab(new QPlainTextEdit, "New tab");
QPlainTextEdit * p = qobject_cast<QPlainTextEdit *>(tabWidget->currentWidget());
p->setPlainText("dsg");@
Compiler get me a error, and thats why i asked you about it -
wrote on 16 Jun 2011, 19:33 last edited by
which error?
-
wrote on 16 Jun 2011, 19:33 last edited by
If i change code:
@ tabWidget->addTab(new QPlainTextEdit, "New tab");
QPlainTextEdit * p = qobject_cast<QPlainTextEdit *>(tabWidget->currentWidget());
if (p)
p->setPlainText("dsg");@
It is work right, but conversion does not occur -
wrote on 16 Jun 2011, 19:34 last edited by
[quote author="Gerolf" date="1308252787"]which error?[/quote]
Access violation when reading -
wrote on 16 Jun 2011, 19:43 last edited by
is the new tab the current one? are you sure?
-
wrote on 16 Jun 2011, 19:44 last edited by
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. -
wrote on 16 Jun 2011, 19:48 last edited by
Many thanks for your help - i find error!
-
wrote on 16 Jun 2011, 20:17 last edited by
What was it? (For those of us who are keeping score...)
-
wrote on 17 Jun 2011, 05:20 last edited by
I'm in the designer created a table and a default is already located there QPlainTextEdit and when I addressed him, it is transformed into kvidget, not QPlainTextEdit
-
wrote on 5 Jun 2013, 11:01 last edited by
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.
-
wrote on 11 Jun 2013, 10:55 last edited by
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)