Search code examples
c++cssqtqmainwindowqdockwidget

Resize QMainwindow to fit Qdockwidget size


I have a QMainWindow and a QDockWidget nested inside this.

I show some graphs, so the QDockWidget expands but the QMainWindow keeps it's initial size so i have to resize it using my mouse.

So, how can i make a QMainWindow resize to QDockWidget size every time?


Solution

  • It was easy at the end.

    I take the Qsize of my QDockWidgets and i resize my QMainWIndow to this.

    For example i have 2 QDockWidget side by side so what i do is

    QSize siz =  Dock->size();
    QSize siz2 =  Dock2->size();
    resize(siz.width()+siz2.width(),siz.height);