Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

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

    General and Desktop
    2
    2
    2576
    Loading More Posts
    • 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
      umen242 last edited by

      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 Reply Quote 0
      • A
        amban last edited by

        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 Reply Quote 0
        • First post
          Last post