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. Changing the (default) circular tab order into a linear one

Changing the (default) circular tab order into a linear one

Scheduled Pinned Locked Moved General and Desktop
selectiontab key
4 Posts 2 Posters 2.5k 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.
  • F Offline
    F Offline
    FrozenTarzan
    wrote on last edited by
    #1

    Hi there,

    I have already posted the problem at stockoverflow if you want to read about others comments: How to break the tab order chain of widgets in Qt?

    My application uses the tab order to navigate through the GUI by pressing keys. I pretty much can control how the tab order (the chain of selectable widgets) is configured and it works but the chain is always closed so that the user can come back to the first widget after the last one.

    So, for example, I have 4 widgets they are connected like this: A - B - C - D - (back to A)
    This means that I can go to D by going back from A and I can go to A by going forward from D. I would like to stay at A so that I can only go forward to B and I want to stay at D so I can only go backwards to C.

    The setTabOrder() does not allow to link a widget to itself so one solution is to insert dummy-objects that redirect the focus. The problem is that my GUI is built dynamically so, for example:
    StartDummy - A - B - C - D - EndDummy
    This works as long as D is inside my chain. If I hide() the widget D the connection to the EndDummy breaks and Qt closes the tab order automatically. This way the user can still go around the widgets.

    Do you have any other suggestions? Is there a way to listen to focus events and ignore them? Even if this would work I had the problem that my widgets have to know if they are the last or first one.

    Thanks! :-)
    Andreas

    1 Reply Last reply
    0
    • F Offline
      F Offline
      FrozenTarzan
      wrote on last edited by
      #2

      I have another idea now. What if i reimplement bool QWidget::focusNextPrevChild(bool next)? According to the docu one can use this to implement custom focus behavior.

      Do anyone have experience with this?

      In my dynamic scenario where buttons in the GUI are adjusted at runtime I will have to overload the function and set, for example, flag "allowFocusNext" and "allowFoxusPrev" which then ignores the focus request if necessary. I will report back here, when I have tried it.

      1 Reply Last reply
      0
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Just a thought.
        If you disable default tab order handling.
        Then build you own list and then onKeyPress just select next from list and in case
        you add / remove elements , update the list.
        Then it would not round trip or do anything besides what you make it.

        1 Reply Last reply
        0
        • F Offline
          F Offline
          FrozenTarzan
          wrote on last edited by
          #4

          Hey mrjj,

          thanks for the comment. I thought about a custom list too but although this would work, it is a huge effort to integrate it in an existing application with many screens and widgets where some of them are created dynamically.

          I have found a working solution by overriding void wheelEvent(QWheelEvent* event) but I'm not happy with it. I posted my solution here.

          I'm still looking for better ideas! :-)

          1 Reply Last reply
          0

          • Login

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