Nominate our 2022 Qt Champions!

QFormLayout formatting

  • Hi,
    I have the following QFormLayout:

    QScrollArea *scrollarea = new QScrollArea(this);
            scrollarea->setVerticalScrollBarPolicy (Qt::ScrollBarAlwaysOn);
            scrollarea->setHorizontalScrollBarPolicy (Qt::ScrollBarAlwaysOn);
            scrollarea->setMinimumWidth (900);
            QWidget *viewport  = new QWidget(this);
            scrollarea->setWidget (viewport);
            scrollarea->setWidgetResizable (true);
            QFormLayout *layout = new QFormLayout(this);
            viewport->setLayout (layout);
    		layout->setSpacing (20);
            //Title Row setup
            QHBoxLayout *titleRow = new QHBoxLayout();
            titleRow->addWidget (Title);
    		//Displaying the rows
    		layout->addRow (titleRow);
            layout->addRow (Label_ID,ID_Display);

    How can I increase the distance between the rows? Is it possible to do different distances for different rows? (For example bigger space between the title and the ID row and set the distance between the other rows of the form.)

    Thank you for your help.

  • Lifetime Qt Champion

    @gabor53 said:
    there is
    layoutVerticalSpacing property.
    You can set minimum sizes on widgets so they take more space but
    the interspace for rows is the same.

    Also, u can always insert a Widget as place holder and use other settings for its layout so the overall effect will be what u need.

Log in to reply