Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/7.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_Qtstylesheets - Fatal编程技术网

Qt 如何禁用QPushButton悬停默认动画

Qt 如何禁用QPushButton悬停默认动画,qt,qtstylesheets,Qt,Qtstylesheets,我创建一个QPushButton,然后添加一个透明图像作为背景。 当我在按钮区域移动鼠标时,有这样的动画效果,看起来像是背景图像被再次粘贴到背景上。如果鼠标悬停,然后向外移动,并重复该操作,则背景图像颜色会越来越深。感觉像是一次又一次地粘贴背景图像。 我只是不希望鼠标悬停时有任何效果,只是简单地显示背景图像是否悬停 QPushButton *mButton = new QPushButton(this); QPixmap pixmap(RETURN_BUTTON_PIC); QString bu

我创建一个QPushButton,然后添加一个透明图像作为背景。 当我在按钮区域移动鼠标时,有这样的动画效果,看起来像是背景图像被再次粘贴到背景上。如果鼠标悬停,然后向外移动,并重复该操作,则背景图像颜色会越来越深。感觉像是一次又一次地粘贴背景图像。 我只是不希望鼠标悬停时有任何效果,只是简单地显示背景图像是否悬停

QPushButton *mButton = new QPushButton(this);
QPixmap pixmap(RETURN_BUTTON_PIC);
QString buttonCSS
("
  QPushButton{background: none; background-color: transparent; border:none;} 
  QPushButton:hover{background: none; border:none;}
");
mButton->setStyleSheet(buttonCSS);
mButton->setIcon(QIcon(pixmap));
mButton->setIconSize(pixmap.rect().size());

顺便说一下,我不希望禁用整个悬停事件,提前感谢您可以完全自定义您的按钮。在这种情况下,将根本没有动画。尝试直接设置边界。例如:
边框:1px实心透明