3
Row{
    width: parent.width
    spacing: ????
    Checkbox{}
    Checkbox{}
    Checkbox{}
    Checkbox{}
}

So just to be clear, the checkboxes should be spaced in such a manner that however wide the row is, it will expand or compress the spacing in accordance to this.

1 Answer 1

4

The simplest solution would be to set width: parent.width/4 for each of the checkboxes. If you want to keep the checkbox width set at some known value, you could instead set spacing: (parent.width - 4 * checkboxwidth)/3 on the Row. Note that this will cause the elements to overlap when the parent is narrow.

If you're targeting Qt 5.1 or higher, you may want a RowLayout. I'm still on 5.0, though, so I can't help you there.

Yet another way to do this would to be to put each CheckBox in an Item. Each Item would have width: parent.width/4, and each CheckBox would have anchors.centerIn: parent. This would give a half-width margin on the far left and far right, which may or may not be desired.

1
  • On 5.3 actually... RowLayout; why didn't I see that? Anyways what I ended up doing is setting the checkbox width manually to units.gu(4), then for spacing: (row.width - units.gu(4[gu]*4[checkboxes]))/3[spaces]. Worked perfectly.
    – Anon
    Aug 22, 2014 at 12:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .