pamxy

为了那么丁点的兴趣,你懂的...

导航

Qt中按钮背景图片的切换设置

转自:http://gjianw217.blog.163.com/blog/static/26144182012871551233/

第一种方法:

 

第二种方法:

使用setStyleSheet()函数进行设置:

如将一个QPushButton类的按钮设置为:

ui->btn_name->setStyleSheet("QPushButton{background-image: url(:/images/call_up.bmp);}" 
"QPushButton:hover{background-image: url(:/images/call_hov.bmp);}" 
"QPushButton:pressed{background-image: url(:/images/call_down.bmp);}");

或者设置为字符串的形式,在初始化时调用:

QString str="QPushButton#btn_name{background-image: url(:/images/call_up.bmp)}" 
                    "QPushButton#btn_name:hover{background-image: url(:/images/call_hov.bmp);}" 
                    "QPushButton#btn_name:pressed{background-image: url(:/images/call_down.bmp);}";

参考1  参考2


posted on 2013-03-19 17:25  pamxy  阅读(2482)  评论(0编辑  收藏  举报