0
문제는 다음과 같습니다.PyQt5 QML currentIndexChanged 신호
self.__engine = QQmlApplicationEngine()
self.__engine.load("main.qml")
website_list = self.__engine.rootObjects()[0].findChild(QObject, "websiteListView")
website_list.currentIndexChanged.connect(self.__website_event_print)
및 신호 처리에 대한 책임이있는 기능 :
ListView {
id: websiteListView
orientation: ListView.Vertical
flickableDirection: Flickable.VerticalFlick
anchors.fill: parent
model: websiteModel
focus: true
highlight: Rectangle { color: "lightsteelblue";}
highlightFollowsCurrentItem: true
objectName: "websiteListView"
delegate: Component {
Item {
property variant itemData: model.modelData
width: parent.width
height: 20
Row {
id: row1
spacing: 10
anchors.fill: parent
Text {
text: name
font.bold: true
anchors.verticalCenter: parent.verticalCenter
}
MouseArea {
id: websiteMouseArea
anchors.fill: parent
onClicked: {
websiteListView.currentIndex = index
}
}
}
}
}
}
내가이 파이썬 스크립트를 가지고 :
은 내가 "main.qml"QML 파일이 목록보기가
@pyqtSlot(int, int)
def __website_event_print(self, current, previous):
print(current)
print(previous)
위의 코드는 전체 응용 프로그램에서 발췌 한 것일 뿐이지 만 다른 줄이 코드는 문제와 관련이 없습니다.
내 응용 프로그램 오류를 실행하려고 바와 같이 이미 위의 코드를하지만 아무것도 작동하는 것 같다의 변화의 풍부한를 시도TypeError: decorated slot has no signature compatible with currentIndexChanged()
발생합니다. 신호를 다루는 제 스타일이 맞습니까? 그렇다면 "currentIndexChanged"의 서명은 무엇입니까?
정말 고마워요! 그것은 작동하고 생각보다 훨씬 간단합니다! 나는 qml에서 foo를 오역 한 것으로 생각하고 재미있게 썼다. – MrKadek750