Just did that, and I am using ::findWidget(*QWidget) to get the widget index number, and it works at first, then it goes haywire.
I have 3 sample widgets included, like this:
startPosition.png
and I can move number 2 up to the top by pushing the up button, like this:
firstClick.png
but if I try to move number 1 back to the top, I get no response. If I push the up button a second time, it doesn't move. In fact, if a push the up buttons a few times, none of them respond.
I have not implemented the other buttons yet.
Here is the relevant code (it is declared as a slot in the header). PositionElementLine inherits QWidget.
void PositionElementBox::up(PositionElementLine *line)
{
int index = boxLayout->findWidget( line );
if(index > 0 ) //an index of 0 means the widget is at the top !!
{
boxLayout->remove(lineList.at(index));
boxLayout->insertWidget( ( index - 1 ), line );
}
}
void PositionElementBox::up(PositionElementLine *line)
{
int index = boxLayout->findWidget( line );
if(index > 0 ) //an index of 0 means the widget is at the top !!
{
boxLayout->remove(lineList.at(index));
boxLayout->insertWidget( ( index - 1 ), line );
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks