Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Qt 6
  4. Muti Selection in PyQt6?
Forum Updated to NodeBB v4.3 + New Features

Muti Selection in PyQt6?

Scheduled Pinned Locked Moved Unsolved Qt 6
5 Posts 3 Posters 1.1k Views
  • 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.
  • B Offline
    B Offline
    bebewinla
    wrote on last edited by
    #1

    I have these following which work in PyQt5 for QtTreeWidget
    self.setSelectionMode(self.ExtendedSelection)
    self.sortByColumn(1,Qt.Qt.AscendingOrder)

    Are those obsolete in PyQt6? What should I use for replacements.

    jsulmJ JonBJ 2 Replies Last reply
    0
    • B bebewinla

      I have these following which work in PyQt5 for QtTreeWidget
      self.setSelectionMode(self.ExtendedSelection)
      self.sortByColumn(1,Qt.Qt.AscendingOrder)

      Are those obsolete in PyQt6? What should I use for replacements.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @bebewinla said in Muti Selection in PyQt6?:

      Are those obsolete in PyQt6?

      Don't know. You did not say what the problem is...

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      B 1 Reply Last reply
      1
      • B bebewinla

        I have these following which work in PyQt5 for QtTreeWidget
        self.setSelectionMode(self.ExtendedSelection)
        self.sortByColumn(1,Qt.Qt.AscendingOrder)

        Are those obsolete in PyQt6? What should I use for replacements.

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by JonB
        #3

        @bebewinla
        Both of the methods are just as available in [Py]Qt6 as they were in [Py]Qt5. [Though PySide6 does not seem to document QTreeWidget.setSelectionModel(), but I don't see why it should not be there.]

        However, I see these two statements each pass a Qt enumerated type value (self.ExtendedSelection, Qt.Qt.AscendingOrder). Could it be on those tokens that you are getting an error message? ISTR that at PyQt6/PySide6 such enum values which were in the global Qt namespace have been moved down into a more specific namespace. So Qt.AscendingOrder needs to become something like Qt.SortOrder.AscendingOrder. I don't know where you look up what these got changed to, and I am not even sure that the PySide6 documentation tells you, but you have to find out somehow....

        1 Reply Last reply
        1
        • jsulmJ jsulm

          @bebewinla said in Muti Selection in PyQt6?:

          Are those obsolete in PyQt6?

          Don't know. You did not say what the problem is...

          B Offline
          B Offline
          bebewinla
          wrote on last edited by
          #4

          @jsulm

          I got this error :
          self.setSelectionMode(self.ExtendedSelection)
          AttributeError: 'Table' object has no attribute 'ExtendedSelection'

          where Table is a QtTreeWidget.
          So I tried the following:
          self.setSelectionMode(self.selectionMode.MultiSelection)
          and it doesn't like it either. See error below

          self.setSelectionMode(self.selectionMode.MultiSelection)
          AttributeError: 'builtin_function_or_method' object has no attribute 'MultiSelection'

          JonBJ 1 Reply Last reply
          0
          • B bebewinla

            @jsulm

            I got this error :
            self.setSelectionMode(self.ExtendedSelection)
            AttributeError: 'Table' object has no attribute 'ExtendedSelection'

            where Table is a QtTreeWidget.
            So I tried the following:
            self.setSelectionMode(self.selectionMode.MultiSelection)
            and it doesn't like it either. See error below

            self.setSelectionMode(self.selectionMode.MultiSelection)
            AttributeError: 'builtin_function_or_method' object has no attribute 'MultiSelection'

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by
            #5

            @bebewinla
            As I suggested, the enumerated type namespaces have changed, you need to use the correct ones in PyQt6.

            Also I don't think it's usual to access a enumerated value via self, e.g. like self.ExtendedSelection, I don't know whether Python allows this.

            1 Reply Last reply
            1

            • Login

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