Document hint lastChild() hack

This commit is contained in:
Florian Bruhin 2014-04-23 14:34:00 +02:00
parent 4661f2c30b
commit 387d0e3be6
2 changed files with 7 additions and 1 deletions

3
THANKS
View File

@ -25,9 +25,10 @@ valuable ones:
- chelmuth - chelmuth
- quark - quark
- Bleeding Fingers - Bleeding Fingers
- artyom.stv
Thanks to these people for helpful bits and pieces in the Qt bugtracker and IRC Thanks to these people for helpful bits and pieces in the Qt bugtracker and IRC
channel: channels:
- Allan Sandfeld Jensen - Allan Sandfeld Jensen
- bachewii - bachewii
- Vitaliy Filippov - Vitaliy Filippov

View File

@ -266,6 +266,11 @@ class HintManager(QObject):
css = self.HINT_CSS.format(left=rect.x(), top=rect.y(), css = self.HINT_CSS.format(left=rect.x(), top=rect.y(),
config=config.instance) config=config.instance)
doc = self._frame.documentElement() doc = self._frame.documentElement()
# It seems impossible to create an empty QWebElement for which isNull()
# is false so we can work with it.
# As a workaround, we use appendInside() with markup as argument, and
# then use lastChild() to get a reference to it.
# See: http://stackoverflow.com/q/7364852/2085149
doc.appendInside('<span class="qutehint" style="{}">{}</span>'.format( doc.appendInside('<span class="qutehint" style="{}">{}</span>'.format(
css, string)) css, string))
return doc.lastChild() return doc.lastChild()