[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

    @setWidget(yourTextEdit)@

    give you what you need? Then the QTextEdit should fill the dockwidget area. See the documentation on "setWidget":http://doc.qt.nokia.com/latest/qdockwidget.html#setWidget



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


  • Moderators

    You need to use
    @
    yourdockwidget->setWidget(...);
    @



  • 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?


  • Moderators

    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.

    @ui->dockWidgetBottomLeft->setContentsMargins(-10,-10,-10,-10);@

    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 );
    this->layout()->setContentsMargins(-10,-10,-10,-10);@



  • i solved it with the following code.
    @QMainWindow::centralWidget()->layout()->setContentsMargins(0,0,0,0);@


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.