Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Drag from QTableView to QListWidget
Qt 6.12 LTS is out! See what's new in the release blog

Drag from QTableView to QListWidget

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.1k Views 2 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.
  • C Offline
    C Offline
    cyrille
    wrote on last edited by
    #1

    Hello,

    I am new to QT and am working on a GUI application sitting on top of some existing code.
    The issue that I am trying to solve is the following:

    I have an existing data structure (read non-QT model) that contains groups of rows of data.

    I display the content of my data structure using a QListWidget to display the names of the groups (simplest solution) and a QTableView (with a QStandardModel to which I add rows of QStandardItem) for the rows of data in the group selected in the QListWidget.

    I want to allow the user to indicate a drag of a row from the QTableView to an item in the QListWidget.
    I do intend to do the data moving operation 'by hand', I am not looking for an automated way to 'do it form we', but am not getting anywhere!

    It seems that I need to accomplish the following tasks.
    When the user does a mouse down in my Table, I need to record an identifier for the item under the cursor

    • how do I do something on mouse down? there does not seem to be any MouseDown signal/slot!
    • how do I equate my cursor coordinates to the QStandardItem at this position?

    When the user moves the mouse by more than n pixels, I need to change the mouse icon to a drag icon

    • how do I do something on mouse down? there does not seem to be any MouseMove signal/slot!
    • how do I change the mouse icon?

    When the user releases the button, I need, if it was released over the List, to find the index of the item under the mouse

    • still no MouseDown signal/slot? how do I know that the user has released the mouse
    • how to I find from the mouse coordinates what is under the mouse?

    Thanks,
    Cyrille

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      Without things being fully automated, why not make use of Qt's item views drag and drop functionality ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

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