Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How can i get the internal QTextEdit used in a QMdiSubWindow

How can i get the internal QTextEdit used in a QMdiSubWindow

Scheduled Pinned Locked Moved General and Desktop
7 Posts 3 Posters 1.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • youzkingY Offline
    youzkingY Offline
    youzking
    wrote on last edited by
    #1

    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 ,

    1 Reply Last reply
    0
    • JeroentjehomeJ Offline
      JeroentjehomeJ Offline
      Jeroentjehome
      wrote on last edited by
      #2

      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.

      Greetz, Jeroen

      1 Reply Last reply
      0
      • youzkingY Offline
        youzkingY Offline
        youzking
        wrote on last edited by
        #3

        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]

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi and welcome to devnet,

          Since both are QObject, you should use qobject_cast

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • youzkingY Offline
            youzkingY Offline
            youzking
            wrote on last edited by
            #5

            whats the difference between dynamic_cast and qobject_cast !!

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              "Here":https://qt-project.org/doc/qt-5/qobject.html#qobject_cast you can find the explanation

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • youzkingY Offline
                youzkingY Offline
                youzking
                wrote on last edited by
                #7

                thanks a lot ^^

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved