PDA

View Full Version : Focus in QDockWidget disappears



Debilski
7th May 2009, 00:47
Hi,
I’m on OS X with Qt 4.5.

In my application I use several QDockWindowswith QSpinBoxs. The problem is that when these are floating and I click inside a dockwindow, the whole dock window does not recieve any focus unless I click its title bar. So, it is not possible to directly select a spin box, as the cursor won’t show up in there. Clicking the up and down arrows of the spin box works, though.

The problem can also be seen with the dockwidgets example from Qt documentation.
When for example I set the paragraphs widget to floating, then click one of the customers, and then click inside the paragraphs widget, the selected line is greyed out, meaning that actually the dockwidget has no focus. After clicking the title bar, however, the line turns blue, which I think should be the default behaviour.

Anyone else having this problem or knows a fix to it?

Thanks

mhoover
18th December 2009, 19:53
I'm having the same problem!

Krishna
28th March 2011, 21:29
I'm having the same problem!

I had the same issue when using QDockWidget. Whenever the dock widget was shown for the first time, its contents wouldn't have focus. Moving the window manually, however, would fix the issue.

Some initial experimentation found that calling activateWindow() on the dock widget would temporarily fix the problem. However, if another window got focus, the same issue would reoccur.

In my particular case, I set the dock widget to initially be floating. That is, I had the floating property checked in Qt Designer in the dock widget properties. To resolve the focus issue, I unchecked this property and then called setFloating(true) after the dock widget was constructed. This seems to fix the issue in my situation.

Krishna
30th March 2011, 12:40
Upon further experimentation, I realized that if you have a custom title bar, you must set the floating property on the QDockWidget after setting the title bar. That did the trick.