QGroupBox moving widgets up and down
-
I am doing a lot of work with lists of objects and have a QGroupBox that is filled with custom widgets. I needed to be able to move them up and down in the list so I used a QGridLayout in the QGroupBox. I use the following code to do the move up. Since I am real new to Qt, I was wondering if there is a better way to do it.
@
void ChannelGroup::MoveToneUp(int pos){
//setTitle("Channel*: " + QString::number(pos));
if (pos > 0){
QWidget prev = theLayout->itemAtPosition(pos -1, 0)->widget();
QWidget curr = theLayout->itemAtPosition(pos, 0)->widget();
theLayout->removeWidget(prev);
theLayout->removeWidget(curr);
theLayout->addWidget(curr, pos -1, 0);
((ToneWidget)curr)->setGridPos(pos -1);
theLayout->addWidget(prev, pos, 0);
((ToneWidget)prev)->setGridPos(pos);
}
}
@