PDA

View Full Version : Tab Ordering not working properly in widget



HunterMetcalfe
25th July 2016, 16:25
Hi everyone,

I'm having an issue and I typically hate asking questions on forums. The issue is the tab order on one of my widgets. I know QT sets tab ordering based upon the order in which the widgets are created in the designer. Luckily this ordering is working. However, the tab ordering is completely off. When I manually set Tab ordering by setTabOrder(widget*, widget*), this tab ordering is also not being followed. Here is an example of some of my code.

setTabOrder(ui->m_tableView, ui->widget);
setTabOrder(ui->widget, ui->m_editWidget);
setTabOrder(ui->m_editWidget, ui->m_setInputWidget);
setTabOrder(ui->m_setInputWidget, ui->m_tableView);

Just as a note m_editWidget and widget are container widgets of spinboxes and other things. m_setInputWidget is a customer widget that was "promoted" using Qt's promote functionality. From my understanding the tab order should tab to these specific widgets and the tab through those widgets sub widgets through the default QWidget::focusNextPrevChild. So if anyone has any ideas or suggestions to help me, I'd be most appreciative.

anda_skoa
25th July 2016, 17:23
Since "ui" suggests you have created the widget in designer, wouldn't it be easiest to just set the tab order in designer?

http://doc.qt.io/qt-5/designer-tab-order.html

Cheers,
_

HunterMetcalfe
25th July 2016, 17:50
I have tried that. The ordering is correct in designer. However, it still is not tabbing properly.

anda_skoa
25th July 2016, 18:26
Hmm, always worked for me but I've never wanted to set focus on a widget that doesn't have keyboard input capability.

Cheers,
_

HunterMetcalfe
25th July 2016, 18:37
What do you think I should do? I would've thought this to be a simple issue. Usually the forum is the last place I go to for help, because typically someone has always asked the question before.

anda_skoa
26th July 2016, 11:29
Well, my approach would be to set the tab order in designer, to each of the input elements.

I.e. if "ui->widget" is not an input widget, it would not be in the tab order chain, only the actual input widgets inside it would be.

Cheers,
_

snowflake09
23rd March 2018, 14:06
Was this ever resolved? I am having a similar problem. I used the 'Edit Tab Order' tool in QtDesigner to set the tab order for a bunch of basic widgets like LineEdits and ComboBoxes. But, when I execute my program, the tab order still follows the original order of creation. I have tried changing the focus policy, which did not make any difference. The tab orders I set show up in the .ui file within <tabstop> tags -- do I have to do something in my main code to recognize these?

d_stranz
23rd March 2018, 18:01
Is your UI file being recompiled (via UIC) when you build your program? If the "ui_xyz.h" file isn't being regenerated on a build after the ui file has changed, then the changes won't show up.

Try manually deleting the ui...h file in the appropriate GeneratedFiles subdirectory. You will get an error if the build dependencies are not set up correctly to build the .h file before it is needed to compile the Qt class that includes it.