I have a qgridlayout which consists of a grid 3 rows and X columns. It starts as one column. I then programatically add columns using "addWidget" adding to rows 0 and 1 in a new column. This works fine. I would like to then delete all the columns (except the first) then start over adding new columns the same way. I tried using "removeItem" but this does not seem to work.
//Add columns
Qlabel label, label2;
layout->addWidget(label1,0,1)
layout->addWidget(gv1,1,1)
layout->addWidget(label2,0,2)
layout->addWidget(gv2,1,2)
//Add columns
QGridLayout *layout = ui->gridlayout;
Qlabel label, label2;
QGraphicsView gv, gv2;
layout->addWidget(label1,0,1)
layout->addWidget(gv1,1,1)
layout->addWidget(label2,0,2)
layout->addWidget(gv2,1,2)
To copy to clipboard, switch view to plain text mode
//Remove columns
layout->columnCount() // 3 as expected
layout->removeItem(layout->itemAtPosition(0,1)
layout->removeItem(layout->itemAtPosition(1,1)
layout->columnCount() // Still 3, expecting 2
layout->removeItem(layout->itemAtPosition(0,2)
layout->removeItem(layout->itemAtPosition(1,2)
layout->columnCount() // Still 3, expecting 1
//Remove columns
QGridLayout *layout = ui->gridlayout;
layout->columnCount() // 3 as expected
layout->removeItem(layout->itemAtPosition(0,1)
layout->removeItem(layout->itemAtPosition(1,1)
layout->columnCount() // Still 3, expecting 2
layout->removeItem(layout->itemAtPosition(0,2)
layout->removeItem(layout->itemAtPosition(1,2)
layout->columnCount() // Still 3, expecting 1
To copy to clipboard, switch view to plain text mode
Bookmarks