https://github.com/satishgoda/learningqt/tree/master/pyside/pyside_basics/jamming/QListWidget
Last active
July 26, 2019 18:55
-
-
Save SatishGodaPearl/dd3de6ce1173b26c97e3ffce054df63a to your computer and use it in GitHub Desktop.
Qt Snippets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PySide2 import QtWidgets | |
from PySide2 import QtCore | |
qlw = QtWidgets.QListWidget() | |
def on_qlw_clicked(): | |
items = qlw.selectedItems() | |
item = items[0] | |
print item.data(QtCore.Qt.UserRole) | |
qlw.clicked.connect(on_qlw_clicked) | |
qlw.show() | |
item = QtWidgets.QListWidgetItem('one') | |
item.setData(QtCore.Qt.UserRole, | |
{'path': "/path/to/one"}) | |
qlw.addItem(item) | |
qlw.addItem('two') | |
items = qlw.selectedItems() | |
item = items[0] | |
item.data(QtCore.Qt.UserRole) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PySide2 import QtWidgets | |
from PySide2 import QtCore | |
qlw = QtWidgets.QListWidget() | |
item = None | |
def on_qlw_clicked(): | |
global item | |
items = qlw.selectedItems() | |
item = items[0] | |
print item.data(QtCore.Qt.UserRole) | |
qlw.clicked.connect(on_qlw_clicked) | |
qlw.show() | |
for manifest_name, manifest in latest_manifests.iteritems(): | |
item = QtWidgets.QListWidgetItem(manifest_name) | |
item.setData(QtCore.Qt.UserRole, | |
manifest) | |
qlw.addItem(item) | |
manifest = item.data(QtCore.Qt.UserRole) | |
manifest.get_description() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment