Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. "Unselect" current item in ListView
QtWS25 Last Chance

"Unselect" current item in ListView

Scheduled Pinned Locked Moved QML and Qt Quick
6 Posts 4 Posters 7.0k 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.
  • M Offline
    M Offline
    mario
    wrote on last edited by
    #1

    I would like to "unselect" the current item in a ListView, for example, after the creation of the ListView or when the ListView loses its focus. If I set currentIndex < 0 the ListView selects (highlights) the first item, but if I set currentIndex >= count it "unselects" the selected item (removes the highlight).

    Is this really the correct behavior for the ListView (the docs say nothing about it)?

    1 Reply Last reply
    0
    • V Offline
      V Offline
      vsorokin
      wrote on last edited by
      #2

      Try

      @MyListView->selectionModel()->clearSelection();@

      --
      Vasiliy

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mbrasser
        wrote on last edited by
        #3

        Hi,

        That doesn't sound like intended behavior to me. Could you please raise a bug in the "bugtracker":http://bugreports.qt.nokia.com? ListView should probably also provide a clearSelection() function or something similar.

        Regards,
        Michael

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mario
          wrote on last edited by
          #4

          @Vass: I think that this will only apply to Widget ListViews and not Quick ListViews. Quick ListViews have no selectionModel-method.

          @mbrasser: Done!

          1 Reply Last reply
          0
          • A Offline
            A Offline
            aviral
            wrote on last edited by
            #5

            how about trying on getting the selected item in list view and then

            selectedItem->setSelection() for required operation.

            1 Reply Last reply
            0
            • M Offline
              M Offline
              mario
              wrote on last edited by
              #6

              [quote author="aviral" date="1280731394"]how about trying on getting the selected item in list view and then

              selectedItem->setSelection() for required operation.[/quote]

              But I don't think I can do that in QML?

              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