[Qt-interest] [Qt/Mac] Stuck with user focus

Frank Mertens frank at cyblogic.de
Sat Jan 24 19:40:39 CET 2009


Try again:

OnScreenKeyboard::OnScreenKeyboard()
	: QWidget(0)
{
	setWindowFlags(Qt::Tool|Qt::FramelessWindowHint);
	setFocusPolicy(Qt::NoFocus);
}

void OnScreenKeyboard::mousePressEvent()
{
	// handle click on my on-screen keys
}

That's Qt44 on OS/X? At least for me it works;)

--
Frank

Sergey Uspensky wrote:
> Thanks for help!!
> 
> yep i've tried Qt::Tool, Qt::FramelessWindowHint but with no use -
> 
> the window don't get focus when i click on it, but focus from other
> application dissapears too (on desktop?).
> 
> if it is focusProxy() then what widget should i setup it?
> 
> thanks again,
> 
> Sergey
> 
> 
> 2009/1/24 Frank Mertens <frank at cyblogic.de>
> 
>> Oh, focus handling can run you mad!-)
>> Watch out window flags Qt::Tool, Qt::FramelessWindowHint for your
>> on-screen keyboard.
>> Maybe QApplication::focusChanged(QWidget*,QWidget*) [signal] and
>> QWidget::focusProxy() may also be your friends in tricking the
>> focus policy.
>> The undesired effects of your mouse clicks you could filter with
>> an event filter ala QWidget::eventFilter().
>> More tricks I don't know.
>>
>> Good luck,
>> --
>> Frank
>>
>> Sergey Uspensky wrote:
>>> Hello guys!
>>> Im developing an application for Mac OS Leopard on Qt - kinda onscreen
>>> keyboard.
>>> The thing is I need to make MainWindow of the application not accepting
>>> keyboard focus (user focus) when user clicks on it choosing possible
>> letters
>>> (keep it always inactivated).
>>>
>>> I have already tried both:
>>>
>>> in Qt 4.4 (it uses Carbon as far as i know) setFocusPolicy(Qt::NoFocus) -
>>> the window stops getting focusEvents but still grabs keyboard focus
>>> and
>>> in Carbon setting kHIWindowBitNoActivates and kWindowNoActivatesAttribute
>>> for this WindowRef
>>>
>>> Both variants didnt work.
>>> Are there any workarounds in Carbon or Qt?
>>>
>>> Afterwards when the window is off-focus I need to send the key to other
>>> application(system wide) which currently has user focus. I think
>>> CGEventCreateKeyboardEvent and then CGEventPost would do the trick?
>>>
>>> Any help will be appreciated.
>>>
>>> TIA,
>>> Sergey
>>>
>>>
>>>
>>> ------------------------------------------------------------------------
>>>
>>> _______________________________________________
>>> Qt-interest mailing list
>>> Qt-interest at trolltech.com
>>> http://lists.trolltech.com/mailman/listinfo/qt-interest
>> _______________________________________________
>> Qt-interest mailing list
>> Qt-interest at trolltech.com
>> http://lists.trolltech.com/mailman/listinfo/qt-interest
>>
> 
> 
> 




More information about the Qt-interest-old mailing list