How to exclude a widget from tab-ordering list?

Tay2510 picture Tay2510 · May 30, 2014 · Viewed 8.9k times · Source

enter image description here

(This picture is from Qt official site, and I take it as an example.)

I'd like to escape some unimportant widgets from being tab-focused.

(This strategy is useful if you have a widget that you want to quickly rotate between some commonly used QLineEdit to enter data and escape those rarely used settings.)

Take the picture as an example, is it possible to exclude Width and Height from tab-ordering list so I can use Tab to rotate only between Name, Color depth, OK and Cancel? I've searched the document and didn't find the option to remove widgets from tab-ordering list.

Answer

thuga picture thuga · May 30, 2014

Change the focus policy of your widgets that you don't want in the tab order list.

The policy is Qt::TabFocus if the widget accepts keyboard focus by tabbing.

You will have to set it to Qt::ClickFocus or Qt::NoFocus to remove it from the tab order list.

See what different focus policies do here.