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. Make QTextEdit resizeable
Forum Update on Monday, May 27th 2025

Make QTextEdit resizeable

Scheduled Pinned Locked Moved Unsolved General and Desktop
19 Posts 4 Posters 2.4k 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.
  • C Offline
    C Offline
    Charon117
    wrote on last edited by Charon117
    #1

    I have a QTextEdit inside of the main window. Now when i move my mouse cursor over the edges of the QTextEdit widget the resize cursors dont appear, and i cant resize it. Does QTextEdit not have a natural window resizing functionality ? How can i get my QTextEdit widget to be resizeable by using the mouse cursor ?

    Edit: mousePressEvent() is already overloaded for the move functionality, so we need to use something else for the resize functionality, most likely the frame, if the frame of QTextEdit can be addressed, and has 8 directional emits, just like a normal window would.

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      When you want to make a widget resizable by the user you have to add QSplitter to your layout.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      1
      • C Offline
        C Offline
        Charon117
        wrote on last edited by
        #3

        Hm ... i dont see a QSplitter in the Qt Designer. I can read up on the class but i dont really know where to implement it. Whats the fundamental problem that i dont understand ? Does QTextEdit simply not have a resizing functionality build in ?

        Christian EhrlicherC 1 Reply Last reply
        0
        • C Charon117

          Hm ... i dont see a QSplitter in the Qt Designer. I can read up on the class but i dont really know where to implement it. Whats the fundamental problem that i dont understand ? Does QTextEdit simply not have a resizing functionality build in ?

          Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Charon117 said in Make QTextEdit resizeable:

          Hm ... i dont see a QSplitter in the Qt Designer.

          Then look again: https://doc.qt.io/qt-6/designer-layouts.html - it's a layout option.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          1 Reply Last reply
          1
          • C Offline
            C Offline
            Charon117
            wrote on last edited by Charon117
            #5

            If QTextEdit doesnt have a built in functionality i would rather like to build it in, instead of using a container to do it for QTextEdit.

            @Christian-Ehrlicher said in Make QTextEdit resizeable:

            @Charon117 said in Make QTextEdit resizeable:

            Hm ... i dont see a QSplitter in the Qt Designer.
            

            Then look again: https://doc.qt.io/qt-6/designer-layouts.html - it's a layout option.

            Its Qt 6 exclusively ? I still cant find it in my Qt Designer.
            Unbenannt.png

            Gojir4G Christian EhrlicherC 2 Replies Last reply
            0
            • C Charon117

              If QTextEdit doesnt have a built in functionality i would rather like to build it in, instead of using a container to do it for QTextEdit.

              @Christian-Ehrlicher said in Make QTextEdit resizeable:

              @Charon117 said in Make QTextEdit resizeable:

              Hm ... i dont see a QSplitter in the Qt Designer.
              

              Then look again: https://doc.qt.io/qt-6/designer-layouts.html - it's a layout option.

              Its Qt 6 exclusively ? I still cant find it in my Qt Designer.
              Unbenannt.png

              Gojir4G Offline
              Gojir4G Offline
              Gojir4
              wrote on last edited by
              #6

              @Charon117 You need at least two widgets for enabling "split" layout option. See the two disabled icons between "Vertical Layout" and "Form Layout" icons. If you have only one widgets, you can resize it by resizing the main window.

              1 Reply Last reply
              0
              • C Charon117

                If QTextEdit doesnt have a built in functionality i would rather like to build it in, instead of using a container to do it for QTextEdit.

                @Christian-Ehrlicher said in Make QTextEdit resizeable:

                @Charon117 said in Make QTextEdit resizeable:

                Hm ... i dont see a QSplitter in the Qt Designer.
                

                Then look again: https://doc.qt.io/qt-6/designer-layouts.html - it's a layout option.

                Its Qt 6 exclusively ? I still cant find it in my Qt Designer.
                Unbenannt.png

                Christian EhrlicherC Offline
                Christian EhrlicherC Offline
                Christian Ehrlicher
                Lifetime Qt Champion
                wrote on last edited by
                #7

                @Charon117 said in Make QTextEdit resizeable:

                f QTextEdit doesnt have a built in functionality

                A widget does not have a user-resize functionality - it's done via the layouts.

                Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                Visit the Qt Academy at https://academy.qt.io/catalog

                1 Reply Last reply
                1
                • C Offline
                  C Offline
                  Charon117
                  wrote on last edited by
                  #8

                  I have plenty of widgets in the main window, but the splitter option is still greyed out.
                  Unbenannt.png

                  Anyway, all of this just seems to be a dead end. Can we simply not build in the resize functionality ? Does QTextEdit have an actual frame, and how can i address it ?

                  JoeCFDJ 1 Reply Last reply
                  0
                  • C Offline
                    C Offline
                    Charon117
                    wrote on last edited by
                    #9

                    I can make the QFrame bigger by setting it to a box and making midLineWidth bigger. But i still dont know (1) how to change the cursor when it hovers over the QFrame and (2) what actually gets triggered when i press on the frame. The frame has to differentiate between all the 8 different directions its pressed on.

                    1 Reply Last reply
                    0
                    • Christian EhrlicherC Offline
                      Christian EhrlicherC Offline
                      Christian Ehrlicher
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      You have to set the splitter between your left layout (which you not yet have) and the textedit - select both -> right click - it's properly documented: https://doc.qt.io/qt-6/designer-layouts.html#splitter-layouts

                      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                      Visit the Qt Academy at https://academy.qt.io/catalog

                      1 Reply Last reply
                      1
                      • C Offline
                        C Offline
                        Charon117
                        wrote on last edited by
                        #11

                        I managed to create a QSplitter at last. What now ? Definitely cant resize it as it stands.

                        Christian EhrlicherC 1 Reply Last reply
                        0
                        • C Charon117

                          I managed to create a QSplitter at last. What now ? Definitely cant resize it as it stands.

                          Christian EhrlicherC Offline
                          Christian EhrlicherC Offline
                          Christian Ehrlicher
                          Lifetime Qt Champion
                          wrote on last edited by Christian Ehrlicher
                          #12

                          @Charon117 said in Make QTextEdit resizeable:

                          Definitely cant resize it as it stands.

                          Save your ui, compile your program, start it and your can move the splitter.

                          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                          Visit the Qt Academy at https://academy.qt.io/catalog

                          1 Reply Last reply
                          0
                          • C Offline
                            C Offline
                            Charon117
                            wrote on last edited by
                            #13

                            LOL. I can move the space inbetween the splitter, eg. between two widgets. WTF is that. I cant (1) move the splitter, or (2) resize the splitter. The space in the splitter is always getting used up 100% by whatever widgets are in. We are back to step zero again. We have the QTextEdit in a container, great. Now we have to built in the functionality to resize the splitter ?

                            Not sure if we are on track with this, this definitely doesnt fullfill the software specification. Which is a freely resizeable QTextEdit.

                            1 Reply Last reply
                            0
                            • C Offline
                              C Offline
                              Charon117
                              wrote on last edited by
                              #14

                              Even if we follow Alice into this wonderland, i only see a vertical and horizontal splitter. If we combine them into the weirdest 4 dimensional 2 layer monster, which would give us "almost" an acceptable outcome it doesnt change the fact that the splitter itself is not moveable, or resizeable. Now we could dock the splitter itself to the main window, which would resize it, ... and we end up with a very weird construct, and several weird bugs.
                              Unbenannt.png

                              Can i just get a hint on how to address the frame of QTextEdit and how to build in the resize functionality itself ?

                              Christian EhrlicherC 1 Reply Last reply
                              0
                              • C Offline
                                C Offline
                                Charon117
                                wrote on last edited by Charon117
                                #15

                                I mean i am pretty sure i can implement the resize functionality with resize(), i just dont get if user input on the frame is generated, how to create the appropriate cursor, and how to connect the user input on the frame, if any is generated, to the resize functionality.

                                1 Reply Last reply
                                0
                                • C Charon117

                                  Even if we follow Alice into this wonderland, i only see a vertical and horizontal splitter. If we combine them into the weirdest 4 dimensional 2 layer monster, which would give us "almost" an acceptable outcome it doesnt change the fact that the splitter itself is not moveable, or resizeable. Now we could dock the splitter itself to the main window, which would resize it, ... and we end up with a very weird construct, and several weird bugs.
                                  Unbenannt.png

                                  Can i just get a hint on how to address the frame of QTextEdit and how to build in the resize functionality itself ?

                                  Christian EhrlicherC Offline
                                  Christian EhrlicherC Offline
                                  Christian Ehrlicher
                                  Lifetime Qt Champion
                                  wrote on last edited by
                                  #16

                                  @Charon117 said in Make QTextEdit resizeable:

                                  nd how to build in the resize functionality itself ?

                                  Reimplement mousePress/mouseMove/mouseRelease event if you don't like to use a QSplitter.
                                  Although I don't understand why this textedit should be resizable in your case - why should the textedit not use all the place it can in the first place? the empty space looks pretty awkward

                                  Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                                  Visit the Qt Academy at https://academy.qt.io/catalog

                                  C 1 Reply Last reply
                                  1
                                  • C Charon117

                                    I have plenty of widgets in the main window, but the splitter option is still greyed out.
                                    Unbenannt.png

                                    Anyway, all of this just seems to be a dead end. Can we simply not build in the resize functionality ? Does QTextEdit have an actual frame, and how can i address it ?

                                    JoeCFDJ Offline
                                    JoeCFDJ Offline
                                    JoeCFD
                                    wrote on last edited by
                                    #17

                                    @Charon117 you need to layout all of them together if resize involves all of them

                                    1 Reply Last reply
                                    0
                                    • Christian EhrlicherC Christian Ehrlicher

                                      @Charon117 said in Make QTextEdit resizeable:

                                      nd how to build in the resize functionality itself ?

                                      Reimplement mousePress/mouseMove/mouseRelease event if you don't like to use a QSplitter.
                                      Although I don't understand why this textedit should be resizable in your case - why should the textedit not use all the place it can in the first place? the empty space looks pretty awkward

                                      C Offline
                                      C Offline
                                      Charon117
                                      wrote on last edited by
                                      #18

                                      Question is still very much open to the people actually reading the question, and understanding it as such. Thank you <3.

                                      Thanks to @Christian-Ehrlicher for pointing out that QTextEdit doesnt have a natural resize functionality, as specified in the question.

                                      1 Reply Last reply
                                      0
                                      • C Offline
                                        C Offline
                                        Charon117
                                        wrote on last edited by Charon117
                                        #19

                                        Message to myself:

                                        Resources gathered so far:
                                        https://forum.qt.io/topic/67019/best-practice-resize-widgets-with-mouse
                                        https://stackoverflow.com/questions/26281192/qt-resizing-a-ui-element-with-the-mouse
                                        https://forum.qt.io/topic/66586/make-a-frameless-qwidget-resizable-with-qrubberband
                                        https://wiki.qt.io/Widget-moveable-and-resizeable

                                        Reflections:
                                        Using QSizeGrip is an easy and dirty solution, but in this case it seems to do the job. Not a good solution if the resizing icon is not desireable to be ontop of the widget.
                                        Widget-moveable-and-resizeable seems to have done some work to make a sort of container for that already, but no time to look into the functionality. It looks promising, depending on the functionality. The QLabels seem to be a bit distracting and maybe unecessary
                                        The most desireable solution would be an invisible container, that allows resizing in 8 directions, and is able to move itself and its content.
                                        QSplitter is not a solution because QSplitter in and of itself is not resizeable, nor moveable. You are basically starting all over again. QSplitter can be a solution if it is embedded in an overall layout, that manages the resizing operation and moving operations. But the underlying form for the desired functionality is freeform, eg. the user defines how the layout looks like. Therefore QSplitter is not a solution.

                                        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