Qt的 - 样式表自定义按钮鼠标悬停和点击 [英] Qt - Stylesheet for custom button on mouse hovered and clicked

查看:3403
本文介绍了Qt的 - 样式表自定义按钮鼠标悬停和点击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想有一种无形的按钮,但是当用户把鼠标停留在上面,我想有一个淡蓝色,而当他点击它,我想有一个深蓝色。

我做了一些研究之后,我想通了,我可以使用样式表功能,但Qt的即时通讯新的,我没有Qt的任何经验,所以我会preFER问和学习。


解决方案

<$p$p><$c$c>yourBtn->setStyleSheet(\"QPushButton{background:url(:/Resources/pause_nor.png);border:0px;}\"
    QPushButton:悬停{背景:网址(:/资源/ pause_over.png);边界:0像素}
    QPushButton:$ P $ {pssed背景:网址(:/资源/ pause_over.png);位置:亲属;顶部:1px的;左:1px的;});

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.

解决方案

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;}");

这篇关于Qt的 - 样式表自定义按钮鼠标悬停和点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆