Important: Please read the Qt Code of Conduct -

Qt Designer Master Layout for Dialog/Mainscreen/etc

  • Hi I was wondering if it is possible to access the master layout used in Qt Designer for a widget. When you create a dialog or mainscreen or whatever in Qt Designer you can right click on the main widget and select Lay Out --> then choose how you want to lay out all the children widgets in the main widget. However when you look at the Object Inspector (the list of all widgets and layouts for the current dialog/mainscreen/etc) there is no entry for the layout you just created by right clicking and choosing layout. I couldn't find any way to access this main grid layout from my code using ui->mastergridlayout->setcolumnstretch or something similar. Is it possible to do so?

  • Lifetime Qt Champion


    It depends partly on what widget you are currently designing. QMainWindow has a custom layout that makes its magic work unlike Widget where you have to first set a layout on it.

  • Thanks SGaist ... so for me I have a QDialog in Designer where I performed the previously mentioned method of laying out by right clicking and setting the layout; can I access this master layout using ui->***** or is this not possible? I'm trying to have the right side of the master gridlayout greedy for extra space when resizing.

  • Lifetime Qt Champion

    Widgets have the layout method that you can use to retrieve it then you can use qobject_cast to cast it to a QGridLayout.

  • Thanks again. What got me was I forgot to cast the QLayout to QGridLayout and therefore couldn't access the methods I needed to.

  • Lifetime Qt Champion

    You're welcome !

    Since you have it working now, please mark the thread as solved using the "Topic Tools" button so that other forum users may know a solution have been found :)

Log in to reply