异常
鼠标点击切换图片(开关声音)时黑屏,每次启动应用第三次切换黑屏(原本是开->关->开->关),只要是全屏就会黑屏(不全屏不闪黑)
异常核心代码
main.cpp
MainWindow w; w.showFullScreen();
mainwindow.cpp
// 加载qml _pQuickView = new QQuickView(); _pQuickView->setSource(QUrl("qml/welcome.qml")); _pQuickWidget = QWidget::createWindowContainer(_pQuickView, this); _pQuickWidget->setGeometry(rect()); _pQuickWidget->show();
qml/welcome.qml
import QtQuick 2.2 Item { property bool mute: false; Image { id: volume; width: 24; height: 24; anchors.right: close.left; anchors.rightMargin: 24; anchors.bottom: close.bottom; source: mute?"../images/no_sound.png":"../images/sound.png"; MouseArea { anchors.fill: parent; onClicked: { mute = !mute; } } } }
解决方法1
直接将Image元素换成AnimatedSprite
import QtQuick 2.2 Item { property bool mute: false; AnimatedSprite{ id: volume; width: 24; height: 24; anchors.right: close.left; anchors.rightMargin: 24; anchors.bottom: close.bottom; source: mute?"../images/no_sound.png":"../images/sound.png"; MouseArea { anchors.fill: parent; onClicked: { mute = !mute; } } } }
解决方法2(推荐)-2017年12月8日
升级Qt版本5.9.3,自身修复了很多bug