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. Stymied with use of setTabOrder
Qt 6.11 is out! See what's new in the release blog

Stymied with use of setTabOrder

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 1.3k 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.
  • D Offline
    D Offline
    drmhkelley
    wrote on last edited by
    #1

    I have searched the archives for useful information, but was unable to find solution to a taborder problem in an app I have been developing.

    I suspect I have some basic misconception about the use of setTaboOrder and would very much appreciate a pointer to some example or demo that illustrates something more than a trivial use of setTabOrder.

    The basic problem (as many others have noted) is that the taborder effective in an application is determined by the order in which I create a bunch of widgets. However, in my application, I often re-sort the inventory. Unfortunately, the original taborder is maintained after sorting, leading to seemingly random taborder. I'd really prefer to tab through the table in the order the inventory is displayed, not the order in which it was created.

    setTabOrder seems designed for this purpose, but it doesn't seem to have any effect, at least in my implementation. Some sketchy details are provided below of the overall structure of the app, but are likely not necessary for helping me get pointed in a better direction.

    IMPORTANT NOTE: The basic app functions very well apart from the tab order issues.

    The application is basically an inventory that is displayed as a table. Each item in the inventory occupies one row of the table, and each item as a fixed set of editable fields that are displayed in the columns. There are controls for which fields of the items are displayed/hidden, and there are controls to sort the inventory by various item fields and to display/hide items that do/don't match search criteria.

    Each inventory item is represented by a widget that contains the required edit fields, let's call it the itemEditorWidget. That widget is a QGridLayout with only one row, but multiple columns for the edit fields. The full inventory is another QGridLayout with only one column containing an itemEditorWidget and a row for each item (it is likely that I could have done this with other box layouts, but QGridLayout gave me the control I needed to get all the stretching to work right).

    All of this is contained in a QScrollArea, which is surrounded by a bunch of other widgets. Because some of these other widgets are created after the initial batch of itemEditorWidgets, any new inventory items really confuse the ultimate tab order. You tab through the initial itemEditorWidgets, then through some other seemingly random widgets, then back into some subsequently itemEditorWidgets, then back into some other dynamically created widgets, then back into more subsequently added itemEditorWidgets, etc, etc, etc.

    MY ATTEMPTED USE OF setTabOrder was very simple. After resorting the table, I tried to use setTabOrder to connect the last edit field of one itemEditorWidget to the first field of the next itemEditorWidget. But that had no apparent effect. I also attempted to use setTabOrder within an itemEditorWidget to scramble the taborder within the widget - also with no effect.

    Hence, I'm pretty sure I'm just doing something dumb that keeps it from working.

    Any suggestions where to look for wisdom?

    1 Reply Last reply
    0
    • Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Please provide a minimal example - since setTabOrder() is widely used I simply would say - it works - so there must be another reason why it does not work for you.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      2
      • D Offline
        D Offline
        drmhkelley
        wrote on last edited by
        #3

        I will be happy to provide a "minimal example" of what I do. However, be forewarned that this could be at best a skeleton of what is going on.

        Since setTabOrder is so commonly used, it seems that giving me a non-trivial example of what works would be a quicker way to my solution. That way the onus is on me, and not someone else, to understand the example.

        For the barest skeleton,


        typedef QList<QWidget*> tEditor;
        typedef QList<type1*> tEditorList;
        typedef QList<QStringList> inventory;

        for (int i=0 ; i<inventory.count() ; i++)
        {
        tEditor* = new tEditor;
        tEditor->setup(inventory.at(i));
        tEditorList.push_back(tEditor);
        }

        idxmax = tEditorList.at(0).count()-1;

        sort(&inventory);

        for (int i=1 ; i<inventory.count() ; i++)
        {
        QWidget* last = inventory.at(i-1).at(idxmax);
        QWidget* next = inventory.at(i) .at(0);
        setTabOrder(last, next);
        }


        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