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. Acceptdrop() is not working in qtableview...??

Acceptdrop() is not working in qtableview...??

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

    hi,
    i'm trying to do drag and drop of contents(text) within a qtableview. here when i try to drag contents , dragging is happening but drop is not happening even though i have included acceptdrop(). i'm not getting whats wrong with my code so can anyone plz solve this issue...??

    @table= new QTableView(this);
    table->setGeometry(10,10,300,200);
    table->setDragEnabled(true);
    table->setAcceptDrops(true);

     model= new QStandardItemModel(5,3,table);
    model->setHorizontalHeaderItem(0,new QStandardItem(QString("header_1")));
     model->setHorizontalHeaderItem(1,new QStandardItem(QString("header_2")));
      model->setHorizontalHeaderItem(2,new QStandardItem(QString("header_3")));
      QStandardItem *item00 = new QStandardItem(QString("data_1"));
      QStandardItem *item01 = new QStandardItem(QString("data_2"));
      QStandardItem *item02 = new QStandardItem(QString("data_3"));
      model->setItem(0,0,item00);
      model->setItem(0,1,item01);
      model->setItem(0,2,item02);
      table->setModel(model);@
    
    1 Reply Last reply
    0
    • JeroentjehomeJ Offline
      JeroentjehomeJ Offline
      Jeroentjehome
      wrote on last edited by
      #2

      Hi,
      The setAcceptDrops() only tells the system that the widget is a able to accept drop, not that it what to do with it.
      Read this:
      "Drag and drop":http://qt-project.org/doc/qt-4.8/dnd.html
      and implement the dropEvent() in your tableView.

      Greetz, Jeroen

      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