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 enable drag row from QtableView(QSqlQueryModel) to other Qtableview(QAbstractTableModel)?
QtWS25 Last Chance

How to enable drag row from QtableView(QSqlQueryModel) to other Qtableview(QAbstractTableModel)?

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

    I need to be able drag row from QtableView A that is using QSqlQueryModel to simple QTableView B
    i followed few links in the net and implemented all info i could find , but still i even can't see the mouse indicator enable me to start the drag from table A and the method in table B not even triggered .
    in Table A (QSqlQueryModel)
    i set in flags
    @Qt::ItemFlags PlayListSqlModel::flags(
    const QModelIndex &index) const
    {
    Qt::ItemFlags defaultFlags = QSqlQueryModel::flags(index);

    if (index.isValid())
    return Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | defaultFlags |Qt::ItemIsSelectable;

    return defaultFlags;
    }@

    in Table B i set :
    @Qt::ItemFlags PlayListPlayerModel::flags( const QModelIndex &index ) const
    {

    Qt::ItemFlags defaultFlags = QAbstractTableModel::flags(index);

    if (index.isValid())
        return Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | defaultFlags |Qt::ItemIsSelectable;
    else
        return Qt::ItemIsDropEnabled | defaultFlags | Qt::ItemIsSelectable;
    

    }@

    also in table B i implemented all the drop methods in the model class

    1 Reply Last reply
    0
    • A Offline
      A Offline
      amban
      wrote on last edited by
      #2

      Hi,
      I was trying to do something similar ...drag from a QListWidget to a QTreeWidget. Adding
      @
      setAcceptDrops()
      @
      to 'true' (for QTreeWidget) worked for me.

      Hope this helps.

      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