QML应用程序和屏幕闪烁

时间:2017-01-08 18:12:58

标签: qml fullscreen

我使用的是Windows 10(已更新),Python 3.5和IDE PyCharm(已完全更新)。

我的问题:单击按钮时屏幕闪烁。

该按钮用于打开“文件”对话框窗口。应用程序窗口通过showFullscreen选项从python端显示(代码如下)。

我该如何解决这个问题。

MktLabelButton.qml

    import QtQuick 2.7

 Item {
    id: mktLabelButton
    x: 10
    y: 10
    width: 48
    height: 48

    signal buttonClicked()

    property alias imageSource : mktLabelButtonIcon.source
    property alias imageLabel  : mktLabelButtonText.text

    Image{
        id: mktLabelButtonIcon
        source: imageSource
        sourceSize.height: mktLabelButton.height
        sourceSize.width: mktLabelButton.width
        scale: mktLabelButtonMouseArea.containsMouse ? 1.2 : 0.85
        Behavior on scale {
            ScaleAnimator {duration: 100}
        }
    }

    Text{
        id: mktLabelButtonText
        font.bold: true
        text: imageLabel
        x: (mktLabelButton.width - contentWidth) / 2
        y: mktLabelButton.height + 5
        color: mktLabelButtonMouseArea.containsMouse ? "yellow":"white"
        Behavior on color {
            ColorAnimation {duration: 100}
        }
    }

    MouseArea{
        id: mktLabelButtonMouseArea
        anchors.fill: mktLabelButtonIcon
        cursorShape: Qt.PointingHandCursor
        hoverEnabled: true
        onClicked: buttonClicked()
    }
}

MainForm.py

    import sys
from PyQt5.QtQml import QQmlApplicationEngine
from PyQt5.QtGui import QGuiApplication
from PyQt5.QtCore import QUrl, QObject
from PyQt5.QtWidgets import QApplication
from PyQt5.QtQuick import QQuickView

class MainForm:

    def __init__(self, parent):
        self.__parent = parent
        self.__openButton = parent.findChild(QObject, "openButton")
        self.__openButton.buttonClicked.connect(self.openButtonClicked)

    def openButtonClicked(self):
        fd = self.__parent.findChild(QObject, "mktFileDialog")
        fd.setProperty("show", "true")



    def show(self):
        pass

if __name__ == '__main__':
    appQueue = QApplication([])
    appEngine = QQmlApplicationEngine()
    appEngine.load(QUrl("file:///E:/QML/01012017/Verison1/qml/mainform/mainform.qml"))
    appWindow = appEngine.rootObjects()[0]
    appWindow.showFullScreen()
    mf = MainForm(appWindow)
    sys.exit(appQueue.exec_())

MktFileDialog.qml

import QtQuick 2.0
import QtQuick.Dialogs 1.2

Item {
    id: mktFileDialog
    objectName: "mktFileDialogPY"

    property alias show: mktFileDialogMain.visible

    FileDialog{
        id: mktFileDialogMain
        title: "Comet görüntüleri"
        visible: show
    }
}

mainform.qml

import QtQuick 2.4
import QtQuick.Controls 1.3
import QtQuick.Window 2.2
import QtQuick.Dialogs 1.2

ApplicationWindow {
    id: root
    width: Screen.width
    height: Screen.height
    color: "black"

    MktLabelButton{
        objectName: "openButton"
        x:50
        y:50
        imageSource: "img/open.png"
        imageLabel: "Open"
    }

    MktFileDialog{
        objectName: "mktFileDialog"
    }
}

0 个答案:

没有答案