How can i get the internal QTextEdit used in a QMdiSubWindow
-
hello ,
i try to make a simple TextEditor ,
and i create a new tab like this :
@m_activatedSubWindow= m_mainZone->addSubWindow(new QTextEdit);
m_activatedSubWindow->show();@
@m_activatedSubWindow@ contains the activated window , so i can change the right window when an action is triggered ,
,
but for example , when i want to color the text of the activated window i can't acces the QTextEditor ,
and when i use @m_activatedSubWindow->widget()@ it returns a @QWidget@ , i used a pointer to save the returned @QWidget@ in a @QTextEdit@ but it tell me that i cant convert them ,i want to access the @QTextEdit@ of the activated window , how can i do ?
thanks for helping , -
How did you cast the returned pointer??
@
dynamic_cast<QTextEdit*>(TheReturnedPointer);
@
would be correct. Because QTextEdit is also QWidget derived, that should work.
You could also hold the QTextEdit pointer as a member variable for further reference. -
thank you this what i was looking for ^^
thanks again ^^
[quote author="Jeroentje@home" date="1403796696"]How did you cast the returned pointer??
@
dynamic_cast<QTextEdit*>(TheReturnedPointer);
@
would be correct. Because QTextEdit is also QWidget derived, that should work.
You could also hold the QTextEdit pointer as a member variable for further reference.
[/quote] -
Hi and welcome to devnet,
Since both are QObject, you should use qobject_cast
-
whats the difference between dynamic_cast and qobject_cast !!
-
"Here":https://qt-project.org/doc/qt-5/qobject.html#qobject_cast you can find the explanation
-
thanks a lot ^^