Selection of item in QListView when selected using Mouse



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


  • Lifetime Qt Champion

    Hi,

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



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


  • Lifetime Qt Champion

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



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

    Thank you ....


  • Lifetime Qt Champion

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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.