Qt - Stylesheet for custom button on mouse hovered and clicked

只谈情不闲聊 提交于 2020-01-01 02:47:07

问题


I would like to have an invisible button, but when the user hovers the mouse on it, I would like to have a light blue color, and when he clicks it, I would like to have a darker blue.

After I did some research, I figured out I can use the stylesheets feature, but im new on Qt and I don't have any experience on Qt, so I would prefer to ask and learn.


回答1:


yourBtn->setStyleSheet("QPushButton{background:url(:/Resources/pause_nor.png);border:0px;}"
    "QPushButton:hover{background:url(:/Resources/pause_over.png);border:0px}"
    "QPushButton:pressed{background:url(:/Resources/pause_over.png); position: relative;top: 1px; left: 1px;}");


来源:https://stackoverflow.com/questions/12292592/qt-stylesheet-for-custom-button-on-mouse-hovered-and-clicked

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!