0

I've read that I can use QStyle.SH_ToolTip_WakeUpDelay to create a delay before the tool tip is shown, but I didn't figured out how exactly. I already read this question: How do I use QStyle::SH_ToolTip_WakeUpDelay to set tooltip wake-up time? I'm not familiar with C++, but I tried to recreate it. I just made a class and overwrited the method styleHint, but it doesn't work.

My code:

class ProxyStyle(QProxyStyle):

    def __init__(self):
        super().__init__()

    def styleHint(self, hint: QStyle.StyleHint, option: Optional['QStyleOption'] = ..., widget: Optional[QWidget] = ..., returnData: Optional['QStyleHintReturn'] = ...) -> int:
        if hint == QStyle.SH_ToolTip_WakeUpDelay:
            return 1000   # I just assumed it's in milliseconds, so I did 1000 to have a delay of 1s.
 
        return QProxyStyle.styleHint(hint, option, widget, returnData)

As the guy answered in the above mentioned question, I added an instance of the class to my application. I don't know exactly if I understood it correctly, but I just did that:

proxyStyle = QProxyStyle()
app = QApplication([proxyStyle])
app.exec()
Edit

I did it like that now, but it also doesn't work (I expect a 1s delay):

proxyStyle = QProxyStyle()
app = QApplication([])
app.setStyle(proxyStyle)
ProMine
  • 53
  • 1
  • 10
puncher
  • 1,570
  • 4
  • 15
  • 38
  • You can set the style with [QApplication::setStyle()](https://doc.qt.io/qt-5/qapplication.html#setStyle) – chehrlic Mar 15 '22 at 10:14
  • I did that but it doesn't work. I edited the question – puncher Mar 15 '22 at 10:26
  • Add a debug output to see if styleHint and your case statement is called at all. – chehrlic Mar 15 '22 at 11:55
  • Create the style *after* the application. Also provide a [mre] and the output of `print(app.style.objectName())` before setting the proxy style. – musicamante Mar 15 '22 at 13:04
  • Please check this answer. https://stackoverflow.com/questions/57007003/qproxystyle-with-qstylesheet – Pavan Chandaka Mar 15 '22 at 17:26
  • Your `styleHint` implementation is broken because `self` isn't passed in the base-class call. Use `return super().styleHint(hint, option, widget, returnData)` instead. Also, insert the line `print('style-hint:', hint)` as the first line of the method to check that it's being called with the relevant hint. – ekhumoro Mar 15 '22 at 22:14

0 Answers0