Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Selection of item in QListView when selected using Mouse
Qt 6.11 is out! See what's new in the release blog

Selection of item in QListView when selected using Mouse

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 2.8k 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.
  • S Offline
    S Offline
    Stoned Jesus
    wrote on last edited by
    #1

    I have a QListView which contains QStandardItemModel which displays thumbnails.

    When I select the items using Mouse, mouseMoveEvent is called followed by selectionChanged.
    The selection scenarions are mentioned below -

    Assume the numbers(1,2,3....) to be the items

    Scenario 1 - In case thumbnail display is 2 horizontal rows.
    [1] [2]
    [3] [4]
    [5] [6]
    [7] [8]
    Lets assume they are displayed as above, then the item selection is in the below order
    1,3,5,7,2,4,6,8

    whereas the expected selection is

    1,2,3,4,5,6,7,8

    Scenario 2- In case thumbnail display is in 3 horizontal rows.
    [1] [2] [3]
    [4] [5] [6]
    [7] [8] [9]
    [10] [11]
    Lets assume they are displayed as above, then the item selection is in below order
    1,2,4,5,7,8,10,11,3,6,9

    where as the expected selection is 1,2,3,4,5,6,7,8,9,10,11

    Can anyone please suggest a way to get the listview item selection as expected?

    I have tried by changing the selectionBehavior and selectionMode too. Currently the selectionBehavior id ExtendedSelection.

    --
    Thanks & Regards,
    Stoned Jesus

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

      Hi,

      Are you selecting your thumbnails from left to right and up to bottom ?

      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
      • S Offline
        S Offline
        Stoned Jesus
        wrote on last edited by
        #3

        The result appears to be the same when I select either from left to right or top to bottom.

        --
        Thanks & Regards,
        Stoned Jesus

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

          Looking at the selectedIndexes documentation I would say that you will have to do the sorting yourself

          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
          • S Offline
            S Offline
            Stoned Jesus
            wrote on last edited by
            #5

            I tried using qsort... It worked..:)

            Thank you ....

            --
            Thanks & Regards,
            Stoned Jesus

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

              You're welcome !

              Don't forget to update the thread's title prepending solved so other forum users may know a solution has been found :)

              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