Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Qt-将边框图像设置为QPushButton会使其失去推送效果_Qt_User Interface_Uibutton_Qt Creator_Qpushbutton - Fatal编程技术网

Qt-将边框图像设置为QPushButton会使其失去推送效果

Qt-将边框图像设置为QPushButton会使其失去推送效果,qt,user-interface,uibutton,qt-creator,qpushbutton,Qt,User Interface,Uibutton,Qt Creator,Qpushbutton,在互联网上搜索,我找到了一种为QPushButton设置自己图像的方法,样式表上有以下行: border-image: url(:/Path/to/my/image.jpg) 0 0 0 0 stretch stretch; 结果外观很好,但失去了“推动效应” 排队 backgound-image: url(:/Path/to/my/image.jpg); 它保持了按键效果,但背景图像不会像“边框图像”那样缩放到按钮的大小 是否有一个技巧我还没有找到,使它与边框图像一起工作,或者我必须更改.

在互联网上搜索,我找到了一种为QPushButton设置自己图像的方法,样式表上有以下行:

border-image: url(:/Path/to/my/image.jpg) 0 0 0 0 stretch stretch;
结果外观很好,但失去了“推动效应”

排队

backgound-image: url(:/Path/to/my/image.jpg);
它保持了按键效果,但背景图像不会像“边框图像”那样缩放到按钮的大小


是否有一个技巧我还没有找到,使它与边框图像一起工作,或者我必须更改.jpg图像的大小,以使我的按钮样式正确?

因此,我找到了一种方法来做我想要的,创建两个不同的jpg图像,并将每个图像设置为在正常状态和按下QPushButton的状态下显示为边框图像,将以下行添加到按钮的样式表中:

QPushButton{ border-image:url(:/path/to/my/image.jpg); QPushButton:pressed{ border-image:url(:/path/to/my/image2.jpg); }

对我来说很有效,我可以说问题已经解决了。

你可以在所有按钮状态上放置一个样式表。

看看Qt文档

实际上,我正在寻找一些只需检查或激活的标志或属性,但我在创建自己的背景和设置状态方面没有问题。谢谢