Boris Gougeon
Boris Gougeon

Reputation: 874

setTabChangesFocus(bool) has no effect Qt

I need to forbid the tab input in a QPlainTextEdit widget. Instead tab should be used has a "focus next" widget. It seems that setTabChangesFocus(bool) is made for that but setting it to true has no effect. I guess it's a Qt bug. Did anyone experiences the same issue and find a solution?

I'm using Qt 4.5.2 on snow leopard.

Thanks, Boris

Upvotes: 0

Views: 410

Answers (3)

Henrik Hartz
Henrik Hartz

Reputation: 3675

The correct solution to this is to use a focus proxy widget. See:

http://doc.qt.io/qt-4.8/qwidget.html#setFocusProxy

Upvotes: 1

Boris Gougeon
Boris Gougeon

Reputation: 874

Thanks Andy, I actually found a solution. It seems that you need to put it inside another widget (a groupbox for example) and it should work.

Boris.

Upvotes: 0

Andy M
Andy M

Reputation: 6065

I'm using Qt 4.5.3 and I quickly tested it in my app, you're absolutely right, setTabChangesFocus(true) should switch from "tab into the TextEdit" to "tab to change focus"...

I'm on windows XP tho, did you reimplement QPlainTextEdit ?

In the meantime, if you really don't find the source of your problem, you could maybe use a EventFilter...

Upvotes: 0

Related Questions