Y
Y
Yelzhas Mukanov2015-08-14 12:29:58
Qt
Yelzhas Mukanov, 2015-08-14 12:29:58

How to clear QGridLayout?

it is necessary to clear the GridLayout from widgets, not to remove the widgets themselves from memory, just so that they are not displayed. This is done in order to redraw these widgets (perhaps in order to delete only one widget, and redraw the rest). But my widgets remain on the Layout but do not react. I use and experiment with the following piece of code

QList<QmyWdiget*> opened_chat;
...
QLayoutItem *poLI;
QWidget *poW;
while((poLI=opened_chat_layout->takeAt(0))!=0){
poW=poLI->widget();
opened_chat_layout->removeWidget(poW);
opened_chat_layout->removeItem(poLI);
//poW->deleteLater();
// delete poW;
// delete poLI;
}
...
opened_chat.removeAt(index);
...
//дальше перестройка виджетов на Layout

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
TriKrista, 2015-08-14
@TriKrista

I used to do it like this:

pCheckBox = (QCheckBox*)gridLayout->itemAtPosition(k, 0)->widget();
gridLayout->removeWidget((QCheckBox*)gridLayout->itemAtPosition(k, 0)->widget());
pCheckBox->hide();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question