Skip to content

Instantly share code, notes, and snippets.

@SatishGodaPearl
Last active July 26, 2019 18:55
Show Gist options
  • Save SatishGodaPearl/dd3de6ce1173b26c97e3ffce054df63a to your computer and use it in GitHub Desktop.
Save SatishGodaPearl/dd3de6ce1173b26c97e3ffce054df63a to your computer and use it in GitHub Desktop.
Qt Snippets
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)
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