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. QListView selection with mouse
Forum Updated to NodeBB v4.3 + New Features

QListView selection with mouse

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 1.9k 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.
  • T Offline
    T Offline
    tokafr
    wrote on last edited by
    #1

    Hello again

    I have such question. I painted the QlistView from delegate and there are some items inside listView
    I want to delete the item which I select with mouse. but I don't know if it automatically selects the row in selection model. does it do it? if it does'n how can I do it?

    thank you.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      Subst27
      wrote on last edited by
      #2

      Hi!

      I think, like this

      model->removeRow(view->selectionModel()->currentIndex().row());

      1 Reply Last reply
      0
      • T Offline
        T Offline
        tokafr
        wrote on last edited by
        #3

        hi
        I'm doing something like that but I wish to know if mouse click selects in the row inside the model.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          Subst27
          wrote on last edited by
          #4

          any row of selectionModel is located in model.

          you can check index if that one is valid if you want

          I don't understand some thing ?

          1 Reply Last reply
          0
          • jerome_isAviableJ Offline
            jerome_isAviableJ Offline
            jerome_isAviable
            wrote on last edited by
            #5

            tokafr: there is some mouse event click function assigned for handle them on event. Also, there is some flags for tell the QListView if this event has to select the row and how to do it.
            After that, there is also many way of handle them: by press mouse button, or by release the button.
            For exemple, to be able to keep some function allready in place in my QTreeView (like unroll the childs to be shown), i used "mouseReleaseEvent" to handle the click of the mouse.
            Also, consider that you have to write a class who is an implmentation of your QListView for do it (and then, include this function inside).

            After handle the event, this give you back an index (this index is also dependent of the flags configuration give to your QListView options), you can use this index from position at event time handle to do something. if you point on index.row(), so you will act on the row of this index item/model.

            I hope this could help you in what you want to do.

            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