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. How to clear the selection of QListView when multiple items are selected?
Forum Updated to NodeBB v4.3 + New Features

How to clear the selection of QListView when multiple items are selected?

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 3.2k 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 am working on a Qt App where I have a QListView. There are few items present in the list. My application requires items to be rearranged according to user's choice. Everything is working fine but I am facing a small issue.

    When I do multiple selection using a mouse i.e. select items by dragging the mouse, it leaves the selection mark on the QlistView even after I do some rearranging operation. I am sure its got something to do with clearing the selection. I tried to use repaint() or clearFocus() but nothing seems to be working.

    I have a mousemoveevent inside which I am doing it:

    @void BinListView::mouseMoveEvent (QMouseEvent *event) {
    
        if (NULL == event) {
            return;
        } else {
    
            if (Qt::LeftButton & event->buttons ()) {
                int nDis = (event->pos () - m_posStart).manhattanLength ();
    
                if (nDis >= QApplication::startDragDistance ()) {
                    startDrag (m_posStart);
                }
            }
    

    #ifdef QT_NO_DEBUG
    QListView::mouseMoveEvent (event);
    QListView::repaint();
    QListView::clearFocus();

    #endif

        }
        repaint();
    } @
    

    If you notice QT_NO_DEBUG area, you will see my clearing focus and repainting but nothing is helping me. ANy solution to this problem?

    P.S.: I am running it in a release mode.

    --
    Thanks & Regards,
    Stoned Jesus

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      I don't really understand you, but maybe what you are looking for is "clearSelection()":https://qt-project.org/doc/qt-4.8/qabstractitemview.html#clearSelection

      (Z(:^

      1 Reply Last reply
      0
      • S Offline
        S Offline
        Stoned Jesus
        wrote on last edited by
        #3

        Clear selection will not let me select the items. My concern is when I am dragging the mouse and selecting set to items, it leaves the selection mark on the list view. Am i clear now?
        [quote author="sierdzio" date="1372325608"]I don't really understand you, but maybe what you are looking for is "clearSelection()":https://qt-project.org/doc/qt-4.8/qabstractitemview.html#clearSelection[/quote]

        --
        Thanks & Regards,
        Stoned Jesus

        1 Reply Last reply
        0
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          I think it's cleared, but then I don't know the solution ;)

          (Z(:^

          1 Reply Last reply
          0
          • S Offline
            S Offline
            Stoned Jesus
            wrote on last edited by
            #5

            Ahhh man..... I am searching for a solution though....
            [quote author="sierdzio" date="1372326096"]I think it's cleared, but then I don't know the solution ;)[/quote]

            --
            Thanks & Regards,
            Stoned Jesus

            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