mardi 21 avril 2015

How to force widgets in QGridLayout be not equally spaced?

qGridLayout.addWidget(button1,    3,0,1,1, Qt::AlignBottom);
//qGridLayout.addWidget(button2,    3,1,1,1, Qt::AlignBottom);
// is there a way to make button1/3/4 stay at cell 1/3/4
// even if button2 is hidden
qGridLayout.addWidget(button3,    3,2,1,1, Qt::AlignBottom);
qGridLayout.addWidget(button4,    3,3,1,1, Qt::AlignBottom);

The problem I'm having is that, when I hide button2, button1/3/4 becomes automatically equally spaced.

I tried

qGridLayout.addItem(new QSpacerItem,3,1,1,1, Qt::AlignBottom);

but it doesn't work.

Aucun commentaire:

Enregistrer un commentaire