How to determine whether a plasmoid has keyboard focus?

Aaron J. Seigo aseigo at kde.org
Sat Feb 19 04:56:44 CET 2011


On Friday, February 18, 2011, Kun Zhang wrote:
> I'm writing a plasmoid in Python with a WebView. The WebView will reload
> the page automatically by a QTimer. But I don't want it to reload itself
> when I'm viewing or typing in the plasmoid, because it will be very
> annoying. So I have to know whether the plasmoid has keyboard focus.
> 
> I tried hasFocus() of both Applet and WebView, but they always return
> False. I also tried to override focusInEvent(), but it's never triggered.

two things you could try:

* calling setFlag(QGraphicsItem::ItemIsFocusable, true) on the applet or the 
webview .. this still may not work (haven't tried) as the webview itself  
likely has the focus

* call webview->mainFrame()->hasFocus() to see when it has focus.

-- 
Aaron J. Seigo
humru othro a kohnu se
GPG Fingerprint: 8B8B 2209 0C6F 7C47 B1EA  EE75 D6B7 2EB1 A7F1 DB43

KDE core developer sponsored by Qt Development Frameworks
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
Url : http://mail.kde.org/pipermail/plasma-devel/attachments/20110218/bb0dc815/attachment.sig 


More information about the Plasma-devel mailing list