Important: Please read the Qt Code of Conduct -

TabOrder in a QWidget with composites widgets

  • Hello all,

    I have a pb with the tab order in my widget. I have a widget that have some custom widgets (Qwidgets that i have pomoted to CustomWidgets), and also some spinboxes and comboboxes. But at the execution, the tab order is never what i expect (it seems that it keeps the widgets creation order). My custom widgets all have a WheelFocus policy.

    I tried to play with the tab order edit mode in the designer, the setFocusProxy of my custom widgets, the setTabOrder method, nothing change the behaviour. Does anyone have an idea of what's happening ? Is there a well knowed bug with composite widgets and tab order ?


  • Lifetime Qt Champion

    Inside the composites CustomWidget, do you use UI file for the sub controls?
    Or do you new them yourself?

  • I use a UI File.

    I reduced the problem to this ('m not sure aymore that it's linked with custom widgets) :

    I have a QMainWindow in which i add a QDockWidget that contains a Widget. This widget is very simple with spinboxes and comboxes inside a QScrollArea. I have edited the tab order with the designer and when i look at the ui file, the tabstops list is OK. When i run a preview of the widget, it's OK too. But at the execution, my tab order is ignored and the tab order is the defaut order (based on the order in which widgets are constructed). I don't get it.

  • Lifetime Qt Champion

    have you looked in the ui_widgetxx file or the setupUI if/how the taborder is set?

  • I just looked at the ui_widgetxx file and at the end of the setupUi, the taborder is correctly set with many calls of QWidget::setTabOrder in the correct order ...

  • Lifetime Qt Champion

    ok, that should work as nothing else later should change it.
    It could be a bug. Have u looked in

    Can you re-create this issue in smaller sample to play with?

  • Ok, my fault, i think i have founded the problem. In fact, i forgotten that the spinbox that i use in in fact a QSpinbox promoted to my custom widget (that inherit QWidget and contains a QSpinBox).

    When i unpromote to a simple QSpinbox, it works. But i still have the problem with my custom widget. I tried :
    inside my customWidget, but it doesn't works ...

  • In conclusion, the problem is that when the focus goes inside a custom widget, it's not able to go back outside just after the inside custom widget ...

  • Lifetime Qt Champion

    ok. so it stays inside widget even if pressing tab liek crazy?

  • No it goes back but at a random position.

  • Lifetime Qt Champion

    Ok. it sounds like bug but hard to say.

Log in to reply