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 to add QWidget to QTextEdit?

How to add QWidget to QTextEdit?

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 638 Views
  • 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.
  • A Offline
    A Offline
    Anonymous_Banned275
    wrote on last edited by
    #1

    I am using class derived from QTextEdit , I can build standard “window” Qt Area window and add Qwidget to it.
    BUT I end up with two independent windows .

    What I need is Qt Area sub-window containing Qwidget .

    12b1d24a-8bac-4460-a91c-ace5b1757367-image.png

    1. What is the standard window area name I want to write the Qwidget "Form" into ?
    2. I coded QWidget as QTextEdit variable and in constructor and it did not accomplish what I wanted.
    JonBJ 1 Reply Last reply
    0
    • A Anonymous_Banned275

      I am using class derived from QTextEdit , I can build standard “window” Qt Area window and add Qwidget to it.
      BUT I end up with two independent windows .

      What I need is Qt Area sub-window containing Qwidget .

      12b1d24a-8bac-4460-a91c-ace5b1757367-image.png

      1. What is the standard window area name I want to write the Qwidget "Form" into ?
      2. I coded QWidget as QTextEdit variable and in constructor and it did not accomplish what I wanted.
      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @AnneRanch
      You cannot add a QWidget to a QTextEdit. A QTextEdit contains text, and that's it, no further widgets.

      What is a "Qt Area window"? If you are still talking about a QMdiArea, and you want to be able to place more than one widget on any of the QMdiSubWindows, you will want to create the child window as a plain QWidget and then add subwidgets onto that. The hierarchy will look like:

      QMdiArea
          QMdiSubWindow
              QWidget
                  QVBoxLayout
                      widget1 (e.g. QTextEdit)
                      widget2 (e.g. QLabel)
                      widget3 (e.g. QComboBox) etc.
      

      If your Form is a QWidget and you want that as a subwindow itself then you can use that Form as the QWidget in the above hierarchy.

      You started out from an example which illustrated MDI windows by using a QTextEdit for each subwindow, because it was designed for editing the text of multiple files. It was not a suitable example (in its use of QTextEdits as the subwindows) if not to be used just for that.

      A 1 Reply Last reply
      1
      • JonBJ JonB

        @AnneRanch
        You cannot add a QWidget to a QTextEdit. A QTextEdit contains text, and that's it, no further widgets.

        What is a "Qt Area window"? If you are still talking about a QMdiArea, and you want to be able to place more than one widget on any of the QMdiSubWindows, you will want to create the child window as a plain QWidget and then add subwidgets onto that. The hierarchy will look like:

        QMdiArea
            QMdiSubWindow
                QWidget
                    QVBoxLayout
                        widget1 (e.g. QTextEdit)
                        widget2 (e.g. QLabel)
                        widget3 (e.g. QComboBox) etc.
        

        If your Form is a QWidget and you want that as a subwindow itself then you can use that Form as the QWidget in the above hierarchy.

        You started out from an example which illustrated MDI windows by using a QTextEdit for each subwindow, because it was designed for editing the text of multiple files. It was not a suitable example (in its use of QTextEdits as the subwindows) if not to be used just for that.

        A Offline
        A Offline
        Anonymous_Banned275
        wrote on last edited by
        #3

        @JonB said in How to add QWidget to QTextEdit?:

        @AnneRanch
        You cannot add a QWidget to a QTextEdit. A QTextEdit contains text, and that's it, no further widgets.

        What is a "Qt Area window"? If you are still talking about a QMdiArea, and you want to be able to place more than one widget on any of the QMdiSubWindows, you will want to create the child window as a plain QWidget and then add subwidgets onto that. The hierarchy will look like:

        QMdiArea
            QMdiSubWindow
                QWidget
                    QVBoxLayout
                        widget1 (e.g. QTextEdit)
                        widget2 (e.g. QLabel)
                        widget3 (e.g. QComboBox) etc.
        

        If your Form is a QWidget and you want that as a subwindow itself then you can use that Form as the QWidget in the above hierarchy.

        You started out from an example which illustrated MDI windows by using a QTextEdit for each subwindow, because it was designed for editing the text of multiple files. It was not a suitable example (in its use of QTextEdits as the subwindows) if not to be used just for that.

        Yes, I am back to the MDI window example and YES I want to modify the hierarchy WITHOUT destroying the current child window class.

        I'll will use your hierarchy and hope it will work.

        I may have said this before - but MDI "example "code flow is not that easy to "decode" .

        The authors "code comments" are pretty skimpy...

        JonBJ 1 Reply Last reply
        0
        • A Anonymous_Banned275

          @JonB said in How to add QWidget to QTextEdit?:

          @AnneRanch
          You cannot add a QWidget to a QTextEdit. A QTextEdit contains text, and that's it, no further widgets.

          What is a "Qt Area window"? If you are still talking about a QMdiArea, and you want to be able to place more than one widget on any of the QMdiSubWindows, you will want to create the child window as a plain QWidget and then add subwidgets onto that. The hierarchy will look like:

          QMdiArea
              QMdiSubWindow
                  QWidget
                      QVBoxLayout
                          widget1 (e.g. QTextEdit)
                          widget2 (e.g. QLabel)
                          widget3 (e.g. QComboBox) etc.
          

          If your Form is a QWidget and you want that as a subwindow itself then you can use that Form as the QWidget in the above hierarchy.

          You started out from an example which illustrated MDI windows by using a QTextEdit for each subwindow, because it was designed for editing the text of multiple files. It was not a suitable example (in its use of QTextEdits as the subwindows) if not to be used just for that.

          Yes, I am back to the MDI window example and YES I want to modify the hierarchy WITHOUT destroying the current child window class.

          I'll will use your hierarchy and hope it will work.

          I may have said this before - but MDI "example "code flow is not that easy to "decode" .

          The authors "code comments" are pretty skimpy...

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by JonB
          #4

          @AnneRanch said in How to add QWidget to QTextEdit?:

          YES I want to modify the hierarchy WITHOUT destroying the current child window class.

          I know. You can keep the class which is derived from QTextEdit if it does something for you. What you cannot do is make that the direct child widget of the QMdiSubWindow IF you want to put some more widgets on the window. Which I think is what you are wanting to do. If you want multiple widgets on a QMdiSubWindow, you need to make its child a Generic QWidget, add a layout to it, and then add whatever widgets you want there (including your QTextEdit). But as long as you keep the QLineEdit as the QMdiSubWindow's widget you're not set up to then add any further widgets.

          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