2 Attachment(s)
Change QVBoxLayout index?
Hi,
I'm defining a palette through QPushButtons, as shown below:
Attachment 7633
If you press one of the buttons, and use arrowUp and arrowDown keys, you can traverse the list.
If you for some reason want to rearrange the list you can do so by:
1. Click one of the buttons
2. Press 'A' if you want the button upwards, or 'Z' if you want it downwards
This is the code:
Code:
delete item;
rightbox->insertWidget(index + 1, paletItems[index]);
paletItems.swap(index,index+1);
rightbox is a QVBoxLayout, and paletitems is a QList containing the buttons.
Here I have clicked the 'color 4' button, and moved it two places down.
Attachment 7634
It works fine except one thing:
When you traverse the palette with the arrow-keys, it is af if the buttons has kept the original index in the layout?
It jumps from 'color 3' to 'color 4', skipping the two colors in between. Very annoying.
Why is this, and can I avoid it?
Can I vhange the index of the layout-items?
Re: Change QVBoxLayout index?
I assume you are relying on the normal focus navigation for "traverse the list". You have rearranged the widgets on screen but they still carry their original tab order information.
Re: Change QVBoxLayout index?
Thank you! Works like a charm...