9.6.1.  Spacing, Stretching, and Struts

[ fromfile: layout.xml id: spacers ]

Figure 9.12. Improved Layout with Stretch and Spacing

Improved Layout with Stretch and Spacing

Example 9.9. src/layouts/stretch/cardtable.cpp

[ . . . . ]
    row = new QHBoxLayout();
    row->addWidget(new Card("td"));
    row->addWidget(new Card("js"));
    row->addWidget(new Card("kc"));
    rows->addLayout(row);
    rows->addStretch(1);                    1
    QVBoxLayout* buttons = new QVBoxLayout();
    buttons->addStretch(1);                 2
    buttons->addWidget(new QPushButton("Deal"));
    buttons->addWidget(new QPushButton("Shuffle"));
    buttons->addSpacing(20);                3
    QHBoxLayout* cols = new QHBoxLayout();
    setLayout(cols);
    cols->addLayout(rows);
    cols->addLayout(buttons);
    cols->addStretch(0);                    4
}
[ . . . . ]

1

Stretchable space for rows.

2

Stretchable space before buttons in column.

3

Fixed spacing after buttons.

4

How does this affect the size of the buttons?