QML: rendering problems after minimizing frameless window

因为在做界面时正好遇到了这个问题,怎么调都调不通,后来一搜发现果然是Qt的bug,至今未修复啊同学……有个凑合的解决方法,但貌似不适用于纯qml界面,只适合混合的

原文看这里:传送门

I’m trying to implement the QML-based UI inside of frameless (Qt::FramelessWindowHint) window.
But QML engine stops responding to mouse clicks after window is minimized via showMinimized() method.

the code follows:

Image {
source: “minimize.png”
scale: mouse.pressed ? 0.8 : 1.0
smooth: mouse.pressed

MouseArea {
    id: mouse
    anchors.fill: parent
    anchors.margins: -5
    onClicked: {
        console.log("MinimizeButton clicked");
        viewer.showMinimized(); // If comment out this line, works fine
    }
}

}
 

After clicking on MouseArea window is minimized as needed. But all Qt Quick controls inside window become frozen after window has been restored.
Windows without Qt::FramelessWindowHint flag are not affected.
showMinimized() is not the only method to reproduce, “Show Desktop” command of OS gives the same effect. OS is Windows XP.

Is there any workaround for this problem?

 

解决方法:



obsessed, we also experienced this problem in one of our projects.
This bug is reported [bugreports.qt.nokia.com] but is not solved yet. Following the link to the bug report, you’ll find this workaround:
void MainWindow::showEvent(QShowEvent *event)
{
QApplication::postEvent(this, new QEvent(QEvent::UpdateRequest), Qt::LowEventPriority);
QWidget::showEvent(event);
}