I have to do a menu in QML that contains the list of items in a directory and, by clicking over one of them, it plays a video (player.play())
This is what I tried, but is not working
___.qml
Menu {
id: menu
contentItem: ListView {
model: ui.textMenu
}
}
Menu {
id: menu
y: -200
x: 100
Repeater{
model: ui.textMenu
MenuItem {
text: textMenu.entry
onClicked:{
player.source = textMenu.address
player.play()
}
} //x: model.x*(videoPlayer.width - 10)
}
}
___.py
self.__textMenu = QStandardItemModel(self)
menuRoles = {entryRole: b"entry", addressRole: b"address"}
self.__textMenu.setItemRoleNames(menuRoles)
def menu(self):
directoryPath = os.path.join(self.__currentPath, r"video" )
entries = os.listdir(directoryPath)
for entry in entries:
menuVoice = QStandardItem()
menuVoice.setData(entry, entryRole)
videoPath = os.path.join(directoryPath, entry)
menuVoice.setData(videoPath, addressRole)