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 get the Index from a ListView
Forum Updated to NodeBB v4.3 + New Features

How to get the Index from a ListView

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

    I'm trying to get the index from a listview when I dragging the item to over.
    I'm using listview.currentIndex but I always get 0 as an index.
    I have also tried using the delegateId.ListVeiw.currentIndex , I get a reference error ReferenceError.

    I need the index so that I may remove the Item from the return index.

    Any help is appreciated.

    JonBJ 1 Reply Last reply
    0
    • A Arnie77

      I'm trying to get the index from a listview when I dragging the item to over.
      I'm using listview.currentIndex but I always get 0 as an index.
      I have also tried using the delegateId.ListVeiw.currentIndex , I get a reference error ReferenceError.

      I need the index so that I may remove the Item from the return index.

      Any help is appreciated.

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @Arnie77
      I am only guessing, but if you mean you are dragging something else over the listview and want to know which item the drag is over(?), won't you need to use QModelIndex QListView::indexAt(const QPoint &p) const ?

      1 Reply Last reply
      0
      • A Offline
        A Offline
        Arnie77
        wrote on last edited by
        #3

        @JonB said in How to get the Index from a ListView:

        QListView
        Thanks for the reply, JonB.

        Here is an Image that would help you understand what I'm trying to accomplish.
        0_1515105017443_6d713752-b746-4122-a9ec-aa551b977eab-image.png

        ListView in on the right and I'm dragging it over to the Item on the left.
        When dragging the from the ListView to the Play Item, I want to know the Index of the ListView Item I'm dragging over to the other the Play Item.

        JonBJ 1 Reply Last reply
        0
        • A Arnie77

          @JonB said in How to get the Index from a ListView:

          QListView
          Thanks for the reply, JonB.

          Here is an Image that would help you understand what I'm trying to accomplish.
          0_1515105017443_6d713752-b746-4122-a9ec-aa551b977eab-image.png

          ListView in on the right and I'm dragging it over to the Item on the left.
          When dragging the from the ListView to the Play Item, I want to know the Index of the ListView Item I'm dragging over to the other the Play Item.

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by JonB
          #4

          @Arnie77

          ListView in on the right and I'm dragging it over to the Item on the left.

          ?? ListView on left and dragging item over to widget at right ??

          This appears to be the opposite way round from what I first understood you to be saying. You seem to be dragging an item out of the listview to somewhere else, not dragging something else over on top of a listview item.

          A 1 Reply Last reply
          1
          • JonBJ JonB

            @Arnie77

            ListView in on the right and I'm dragging it over to the Item on the left.

            ?? ListView on left and dragging item over to widget at right ??

            This appears to be the opposite way round from what I first understood you to be saying. You seem to be dragging an item out of the listview to somewhere else, not dragging something else over on top of a listview item.

            A Offline
            A Offline
            Arnie77
            wrote on last edited by
            #5

            @JonB

            Yes, that is what I meant.

            1 Reply Last reply
            0
            • VRoninV Offline
              VRoninV Offline
              VRonin
              wrote on last edited by
              #6

              in the play area you'll have a drop event that contains the QMimeData with the information you need

              "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
              ~Napoleon Bonaparte

              On a crusade to banish setIndexWidget() from the holy land of Qt

              1 Reply Last reply
              3
              • A Offline
                A Offline
                Arnie77
                wrote on last edited by
                #7

                I was able to figure out how to access the index.
                I was trying to access it via listview.currentIndex, but that only seems to work when using the keyboard arrow keys to move between items. If you are using the mouse then index from the ListModel it what you want use.

                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