새로운 PyQt5 응용 프로그램이 있습니다. QMainWindow 내부에 QQuickWidget을 추가하고 QML을 사용하여 속성을 설정하려고했습니다.클릭 상태가 PyQt5 일 때만 직사각형의 상태가 변경됨 QML
class mainWindow(QtWidgets.QMainWindow):
def __init__(self):
super(mainWindow,self).__init__()
self.setGeometry(100,100,800,600)
engine = PyQt5.QtQml.QQmlEngine(self)
view = QtQuickWidgets.QQuickWidget(engine,self)
view.setSource(PyQt5.QtCore.QUrl("files/newqml.qml"))
마우스 버튼을 유혹 할 때 변경해야 내가 미국에 사각형을 만들 QML 파일로 : 이것은 내가 할 것입니다. 그러나 그것이 공중에 떠있을 때 - 아무 일도 일어나지 않습니다. 단추를 클릭 할 때 상태가 변경되고 단추를 클릭하고 떠날 때 상태가 변경됩니다. 도와주세요, 제발. 어떻게해야 제대로 할 수 있습니까?
전체 QML 코드 :
import QtQuick 2.3
import QtQuick.Controls 1.2
import QtQuick.Window 2.2
import QtQuick.Controls.Styles 1.2
Rectangle{
signal buttonPressedSignal
signal buttonReleasedSignal
id: topButton
width:80
height: 40
color: 'white'
border {width: 2; color: '#4CAF50'}
state: 'Normal'
Text {
id: buttonText
anchors.centerIn: parent
text:'Button'
font.pixelSize: 20
font.family: 'Hallo sans'
color: 'black'
}
MouseArea{
anchors.fill: topButton
hoverEnabled: true
onPressed: parent.buttonPressedSignal()
onReleased: parent.buttonReleasedSignal()
onEntered: parent.state='NotNormal'
onExited: parent.state = 'Normal'
}
states:[
State{
name: 'Normal';
PropertyChanges{target:buttonText;color:'black';easing.type:Easing.InOutElastic}
},
State{
name:'NotNormal';
PropertyChanges{target:buttonText;color:'white';easing.type:Easing.InOutElastic}
}
]
transitions:[
Transition{
to: '*'
ColorAnimation{target:buttonText;duration:400}
}
]
}
당신은 QML 코드 – eyllanesc
를 배치 할 수 있습니다 나는 코드를 추가 – Polly