qt - Dynamically change position of grid layout items -
i have grid layout shows images on image bellow. want able swap 2 images @ position.
the hierarchy this:
scrollarea->gridlayout->label[n]->pixmap
there n labels in grid layout created dynamically in code.
it possible delete create again in column/row want, i'm trying find more elegant way this. tips?
if want use grid layout...
void yourclass::swapwidgets(qwidget *widgeta, qwidget *widgetb) { int indexa = yourgridlayout->indexof(widgeta); int indexb = yourgridlayout->indexof(widgetb); int row1, column1, rowspan1, columnspan1; int row2, column2, rowspan2, columnspan2; yourgridlayout->getitemposition(indexa, &row1, &column1, &rowspan1, &columnspan1); yourgridlayout->getitemposition(indexb, &row2, &column2, &rowspan2, &columnspan2); yourgridlayout->takeat(indexa); yourgridlayout->takeat(indexb); yourgridlayout->addwidget(widgetb, row1, column1, rowspan1, columnspan1); yourgridlayout->addwidget(widgeta, row2, column2, rowspan2, columnspan2); }
Comments
Post a Comment