Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

[Solved]QToolButton Hover event



  • I'm trying to set a background-color on a QToolButton when hovering another one. Do you know if I can use a hover event or something related to the "hover event" behavior?
    Thanks!



  • Maybe :hover pseudo state will help you?



  • Don't now if it works with pseudo states, how can I refer to the second QToolButton from the first button's stylesheet?

    @button1->setStylesheet(" QToolButton:hover{\n"
    " can I change background of another button?}"); @



  • No you can't do it. You can set global app stylesheet or stylesheet on widget containing these buttons with using ids in scopes (id is equal to objectName).



  • Did it old style : on enterEvent( leaveEvent ) for those two buttons emited signals( StartHover and EndHover ) to parent widget were I added some slots that catch those signals and set the styleSheet accordingly


Log in to reply