Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- from PySide6.QtWidgets import QStyleFactory
- from PySide6.QtWidgets import QApplication, QMainWindow, QListWidget, QListWidgetItem, QVBoxLayout, QWidget
- from PySide6.QtCore import Qt
- class MainWindow(QMainWindow):
- def __init__(self):
- super().__init__()
- self.setWindowTitle("All rows should be checkable, only the first one is.")
- layout=QVBoxLayout()
- checklist=QListWidget()
- # Uncommentting the following line fixes the issue (with a different style)
- #checklist.setStyle(QStyleFactory.create("Fusion"))
- checklist.clear()
- # Add 3 checkable rows.
- for name in ["foo", "bar", "baz"]:
- item=QListWidgetItem(name)
- item.setFlags(Qt.ItemIsUserTristate|Qt.ItemIsUserCheckable|Qt.ItemIsEnabled|item.flags())
- item.setCheckState(Qt.Checked)
- checklist.addItem(item)
- layout.addWidget(checklist)
- central=QWidget()
- central.setLayout(layout)
- self.setCentralWidget(central)
- app=QApplication(sys.argv)
- win=MainWindow()
- win.show()
- app.exec()
Advertisement
Add Comment
Please, Sign In to add comment