• 9241阅读
  • 8回复

关于重载QPushButton的PaintEvent [复制链接]

上一主题 下一主题
离线kof7845
 
只看楼主 倒序阅读 楼主  发表于: 2009-08-19
小弟想做出这样一个效果的button,在不点,鼠标按下,鼠标抬起来的3种状态下button显示3个不同的背景图片+不同的button文字.
我的做法是
创建一个新类CustomedButton,它继承了QPushButton,
我在重载PaintEvent的时候,不知道怎样才能得到当前BUTTON的状态,从而选择不同的图片.
谁知道教教我啊.
BTW,我不想用QSS,我的QT是4.5.1
谢谢.

离线dbzhang800

只看该作者 1楼 发表于: 2009-08-19
你说的 不点,鼠标抬起 这两个状态之间有区别么?
没区别的话,就两个状态了,两个状态一个 down 属性就够了
离线rqzrqh

只看该作者 2楼 发表于: 2009-08-20
有函数可以获得当前状态的,自己查手册
离线hiti_tony
只看该作者 3楼 发表于: 2009-08-21
重载鼠标的press和release事件
离线kof7845
只看该作者 4楼 发表于: 2009-08-21
引用第1楼dbzhang800于2009-08-19 18:12发表的  :
你说的 不点,鼠标抬起 这两个状态之间有区别么?
没区别的话,就两个状态了,两个状态一个 down 属性就够了

这个down 属性怎么才能查询到啊?
离线kof7845
只看该作者 5楼 发表于: 2009-08-21
引用第2楼rqzrqh于2009-08-20 08:31发表的  :
有函数可以获得当前状态的,自己查手册

能再给些提示吗?
离线dbzhang800

只看该作者 6楼 发表于: 2009-08-21
引用第4楼kof7845于2009-08-21 09:55发表的  :
这个down 属性怎么才能查询到啊?


要习惯看 manual:

down : bool

This property holds whether the button is pressed down.

If this property is true, the button is pressed down. The signals pressed() and clicked() are not emitted if you set this property to true. The default is false.

Access functions:

bool isDown () const
void setDown ( bool )
离线kof7845
只看该作者 7楼 发表于: 2009-08-21
引用第6楼dbzhang800于2009-08-21 10:24发表的  :
要习惯看 manual:
down : bool
.......

谢谢.问题已得到解决.
离线downstairs

只看该作者 8楼 发表于: 2011-02-26
..paintevent函数好麻烦
喜爱编程的猫头鹰
快速回复
限100 字节
 
上一个 下一个