Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
[SOLVED] Synchronizing tab ordering with button ordering
Jakob last edited by Jakob
In my application I have some function that requires a whole bunch of parameters. There is a tabbed settings panel, that can be used to configure four 'presets'. Additionally there is a 'start' button for each of these four parameter configurations. These buttons are (currently) in a HBoxLayout.
I'd like these buttons to follow the ordering of the tabs in the settings panel. I.e. if I move the second tab the first location, the second button should move in front inside the horizontal layout as well.
Is anyone aware of existing code that already does it? Otherwise, how could I do this? (in particular I don't have a clue how to reorder the buttons in the horizontal layout, if at all possible)
For bonus, I'd like to be able to update the layout of the buttons already while dragging the tab, so don't wait for the
tabMovedsignal before updating the button ordering.
AFAIK there's nothing ready made for that. Without the bonus part you can simply take the button out and use insert to put it at the right place back in.
Hope it helps
Jakob last edited by
Thanks for the reply. It confirmed my suspicions.
What I didn't realize before however, is that the
tabMovedsignal is actually emitted independent on whether the mouse is still down or not. GREAT! I created a very simple prototype, and as it turns out, I get everything I want, including the bonus feature by simply connecting to
QTabBar::tabMovedand in the slot writing a line along the lines of the following:
m_viewis an instance of the prototype widget I created,
HBoxLayoutthat holds the same number of buttons as the tab bar.
Thanks for sharing your solution :)