mengtianwxs 发表于 2021-9-14 16:30:26

Qt5界面从最小化点击之后,无法响应鼠标hover样式了




鼠标点击最小化之后重新点击任务栏的图标软件再显示出来之后,无法响应qss hover样式,请问是什么问题造成的(无边框方案)? ShowEvent中设置setAttribute(Qt::WA_Mapped); 也是无效的。现在唯一可行的是用鼠标任意单击一下软件界面,又可以了,不知道是什么问题,考虑用鼠标模拟点击解决一下,还是无法解决。







QPoint pos(10,10);

                QWidget* child = this->childAt(pos);
                  QMouseEvent *pressEvent, *releaseEvent;
                  pressEvent = new QMouseEvent(QEvent::MouseButtonPress, QPoint(10, 10), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
                  releaseEvent = new QMouseEvent(QEvent::MouseButtonRelease, QPoint(10, 10), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
                  QApplication::sendEvent(child, pressEvent);
                  QApplication::sendEvent(child, releaseEvent);

wdmxtk002 发表于 2021-9-15 14:15:44

本帖最后由 wdmxtk002 于 2021-9-15 14:18 编辑

重写一些这个方法试试
void showEvent(QShowEvent *e)
{
this->setAttribute(Qt::WA_Mapped);
QWidget::showEvent(e);}

mengtianwxs 发表于 2021-9-15 14:29:04

wdmxtk002 发表于 2021-9-15 14:15
重写一些这个方法试试
void showEvent(QShowEvent *e)
{


谢谢!这个方法试过了。解决不了问题。
https://www.cnblogs.com/hellovenus/p/5263097.html
https://blog.csdn.net/haluoluo211/article/details/46930187
https://bugreports.qt.io/browse/QTBUG-17548
这几个上面 的都试过了,解决了不。
页: [1]
查看完整版本: Qt5界面从最小化点击之后,无法响应鼠标hover样式了