qt5.9

Registering a Python list property to QML in pyside2

删除回忆录丶 提交于 2019-11-29 08:59:59
I'm trying to load a spreadsheet and pass a list of the worksheets back to my QML interface. But I'm unable to find a way to provide a list(and later a dictionary) back to the QML script. Here's my QML: FileDialog { id: openDialog title: "Open spreadsheet" nameFilters: [ "Excel files (*.xls *.xlsx)", "All files (*)" ] selectedNameFilter: "Excel files (*.xls *.xlsx)" onAccepted: { file.load(fileUrl) console.log(file.name) console.log(file.sheetnames) } onRejected: { console.log("Rejected") } } Here's the my python class: class File(QtCore.QObject): def __init__(self, *args, **kwargs): super

Registering a Python list property to QML in pyside2

青春壹個敷衍的年華 提交于 2019-11-26 21:45:23
问题 I'm trying to load a spreadsheet and pass a list of the worksheets back to my QML interface. But I'm unable to find a way to provide a list(and later a dictionary) back to the QML script. Here's my QML: FileDialog { id: openDialog title: "Open spreadsheet" nameFilters: [ "Excel files (*.xls *.xlsx)", "All files (*)" ] selectedNameFilter: "Excel files (*.xls *.xlsx)" onAccepted: { file.load(fileUrl) console.log(file.name) console.log(file.sheetnames) } onRejected: { console.log("Rejected") } }