Programmatically setting tab order in a hierarchy of widgets



  • I have a problem with ordering widgets that are dynamically added and removed within a hierarchy. For simplicity lets say that I have three QFrame's that are static and within each frame I am dynamically adding and removing QPushButtons. The frames have Qt::NoFocus and I want to ensure that when tabbing from the last button in frame 1 the focus goes to the first button in frame 2, and so on in a circular manner back to the first button in frame 1. I can achieve this by calling QWidget::setTabOrder() on all buttons in all frames each time a button is added. However, I would really like if I could restrict the setTabOrder() to the buttons in the frame in which I added a button, not having to bother with tab ordering in the other frames. Is this possible? Can I somehow specify that at top-level the order of frames is 1, 2, 3 and then build the tab chains for the buttons within each frame individually?

    Thanks



  • As far as I know, the tab order is "global" to a specific window, so I doubt you can save something here.

    As you're adding the buttons programmatically, I would just have three QWidgetLists (typedefs for QList<QWidget *>) that contain all the buttons and iterate over them once a new button is added and call setTabOrder.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.