Setting setItemAlignment breaks setSelectionMode in QListWidget
Unsolved
Qt for Python
-
It seems like setting setItemAlignment breaks setSelectionMode in QListWidget.
Here an example:import sys from PyQt6.QtWidgets import QApplication, QListWidget, QVBoxLayout, QWidget from PyQt6.QtCore import Qt class ListWidgetDemo(QWidget): def __init__(self): super().__init__() layout = QVBoxLayout() self.list_widget = QListWidget() self.list_widget.setItemAlignment(Qt.AlignmentFlag.AlignLeft) self.list_widget.setSelectionMode(QListWidget.SelectionMode.ContiguousSelection) for i in range(10): self.list_widget.addItem(f"Item {i + 1}") layout.addWidget(self.list_widget) self.setLayout(layout) if __name__ == "__main__": app = QApplication(sys.argv) demo = ListWidgetDemo() demo.show() sys.exit(app.exec())
It is possible to select multiple items with mouse using item click + mouse drag.
But this is not the case with the item click + Shift + another item click. In the second case , it seems that ContiguousSelection it works the same as SingleSelection.
Is this a bug?Win 11Pro 23H2
PyQt6 6.7.1
PyQt6-Qt6 6.7.2
PyQt6_sip 13.8.0 -
Hi,
It seems you have indeed found something. It's reproducible as well in C++.
You should open a ticket on the bug tracker with you reproducer (don't forget to check if something similar has already been reported).