user1899020
user1899020

Reputation: 13575

How to removing remaining spacing after hide a row in QFormLayout

Hide a row by the following code

field.hide()
formLayout.labelForField(field).hide()

One disadvantage of the above is that while the items in the row are hidden the spacing above and below the row remains, that is, the rows above and below the hidden row appear further spread apart than the rest of the items in the layout. How to removing remaining spacing after hide a row in QFormLayout?

Upvotes: 14

Views: 5177

Answers (1)

Anatoli
Anatoli

Reputation: 139

Hide:

field->hide();
label->hide();
formLayout->removeWidget(field);
formLayout->removeWidget(label);

Show:

formLayout->insertRow(row, label, field);
label->show();
field->show();

Upvotes: 5

Related Questions