PDA

View Full Version : problem with setFocus( Qt::MouseFocusReason )



winkle99
1st March 2011, 03:19
Has anyone noticed a problem with setFocus in 4.6.2. I've got a couple of lines of code that were working in our previous version of Qt. (4.4)

I have a fairly simple dialog with two widgets (both derived from QListView) After a user action in listView_2 I call setFocus in order to switch the focus back to listView_1. The intention being to give listView_1 keyboard focus. However, I'm now finding that this is no longer working.

in setupUI:


listView_1 = new QListView( this );
listView_1->setFocusPolicy( Qt:NoFocus );


listView_2 = new QListView( this );
listView_2->setFocusPolicy( Qt:NoFocus );

in my slot I call


listView_1->setFocus( Qt::MouseFocusReason );


listView_1 never shows that it has focus. When I hit the arrow key to traverse the items in the list nothing happens. But if I hit the tab key until listView_1 gets focus then things work as expected.

Has anyone else run into this? Am I using the setFocus method incorrectly? Have I missed something?

Thanks.