Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. Setting setItemAlignment breaks setSelectionMode in QListWidget
Forum Updated to NodeBB v4.3 + New Features

Setting setItemAlignment breaks setSelectionMode in QListWidget

Scheduled Pinned Locked Moved Unsolved Qt for Python
2 Posts 2 Posters 189 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    George55978
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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).

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved