Important: Please read the Qt Code of Conduct -

[SOLVED] textEdit: how to remove the margins of mainwindow

  • when putting the textEdit widget inside of a dock widget and maximizing the textEdit widget, it does not maximize to the border of the dock widget. Instead, there is about a 20 pixel gap in between the maximized textEdit widget and the dock widget. How, through style sheets probably, can i get the edges of the maximized textEdit widget to be at the border of the docked widget? in the dock method, I have tried to setContentsMargins() to 0 but that have no effect.

  • Does calling


    give you what you need? Then the QTextEdit should fill the dockwidget area. See the documentation on "setWidget":

  • i am getting the error: 'setWidget' was not declared in this scope

  • Moderators

    You need to use

  • i got it set correctly now. thank you.

    I have push buttons in the dock widget and now they are gone. how can i get them back while using the setWidget?

  • Try setlayout and add all your widgets to that layout...

  • i found that the following code also works great. does anyone know how to set the margins for the textEdit that is maximized in the mainwindow and without any dock widget? I would like to get the textEdit closer to the edge of the screen.


    why is the following code not working. its should remove the margins around the textEdit when not inside of a dock widget. the dock widgets is surrounding the mainwindow widget.

    @this->layout()->setMargin( 0 );

  • i solved it with the following code.

Log in to reply