zlacelle
8th July 2008, 21:25
I've used Qt Designer to create a QWidget with a grid layout on it, containing checkboxes which are dynamically created in my code and correspond to a number in a file on my computer. When a file is changed on the machine, I need the layout to refresh with a number of check boxes equal to a new specified number in the file. I'm trying to use the following code:
//Refresh the layout
ui.TPCheckBoxLayout_G->invalidate();
ui.TPCheckBoxLayout_G->activate();
ui.TPCheckBoxLayout_G->update();
QWidget::repaint();
I call this code right after I delete all of the items from the layout, using the following code:
//Refresh checkboxes and buttons
int rowCount = ui.TPCheckBoxLayout_G->rowCount();
int columnCount = ui.TPCheckBoxLayout_G->columnCount();
for(int i=0; i<rowCount; i++)
{
for(int j=0; j<columnCount; j++)
{
//Clear the TP layout
ui.TPCheckBoxLayout_G->removeItem(ui.TPCheckBoxLayout_G->itemAtPosition(i,j));
delete ui.TPCheckBoxLayout_G->itemAtPosition(i,j);
}
}
}
However, after this code finished, the new boxes are present, but they appear over the old boxes, which don't exist in my code! My new stuff appears, but the old stuff doesn't go away. Any idea what I'm doing wrong?
//Refresh the layout
ui.TPCheckBoxLayout_G->invalidate();
ui.TPCheckBoxLayout_G->activate();
ui.TPCheckBoxLayout_G->update();
QWidget::repaint();
I call this code right after I delete all of the items from the layout, using the following code:
//Refresh checkboxes and buttons
int rowCount = ui.TPCheckBoxLayout_G->rowCount();
int columnCount = ui.TPCheckBoxLayout_G->columnCount();
for(int i=0; i<rowCount; i++)
{
for(int j=0; j<columnCount; j++)
{
//Clear the TP layout
ui.TPCheckBoxLayout_G->removeItem(ui.TPCheckBoxLayout_G->itemAtPosition(i,j));
delete ui.TPCheckBoxLayout_G->itemAtPosition(i,j);
}
}
}
However, after this code finished, the new boxes are present, but they appear over the old boxes, which don't exist in my code! My new stuff appears, but the old stuff doesn't go away. Any idea what I'm doing wrong?