Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Programmatically setting tab order in a hierarchy of widgets
Forum Update on Monday, May 27th 2025

Programmatically setting tab order in a hierarchy of widgets

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 5.8k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jakob Schou
    wrote on 11 Aug 2011, 09:46 last edited by
    #1

    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

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on 11 Aug 2011, 12:26 last edited by
      #2

      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.

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0

      1/2

      11 Aug 2011, 09:46

      • Login

      • Login or register to search.
      1 out of 2
      • First post
        1/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved