Results 1 to 1 of 1

Thread: How to get a QTableWidgetItem to accept drops instead the whole QTableWidget?

  1. #1
    Join Date
    Jan 2008
    Location
    Davao City, Philippines
    Posts
    77
    Thanks
    16
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default How to get a QTableWidgetItem to accept drops instead the whole QTableWidget?

    Hello!

    I 'm fighting a little bit with a QTableWidget. There are three columns in it and I like to have only the QTableWidgetItems in one column editable and to accept drops.

    First I have created the tableWidget using the designer and there I have dragDropMode=No DragDrop for the QTableWidget itself. Then I've created my items like this:

    Qt Code:
    1. for ( int i = 0; i < query.size(); ++i )
    2. {
    3. tableWidget->insertRow( i );
    4.  
    5. QTableWidgetItem *newItemField = new QTableWidgetItem( query.value( 0 ).toString() );
    6. tableWidget->setItem( i, 0, newItemField );
    7.  
    8. QTableWidgetItem *newItemTyp = new QTableWidgetItem( query.value( 1 ).toString() );
    9. tableWidget->setItem( i, 1, newItemTyp );
    10.  
    11. QTableWidgetItem *newItemValue = new QTableWidgetItem( "" );
    12. tableWidget->setItem( i, 2, newItemValue );
    13. newItemValue->setFlags ( Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsDropEnabled );
    14.  
    15. qDebug() << newItemValue->flags();
    16.  
    17. query.next();
    18. }
    To copy to clipboard, switch view to plain text mode 

    qDebug() << newItemValue->flags() shows me 42. If I am right, 42 means, the item is enabled, is editable and will accept drops.

    The problem is, it's enabled (at least it's not grey) but it's not editable and it don't accept drops.

    Where I have done the mistake in thinking?

    Regards

    Guenther
    Last edited by gboelter; 6th October 2010 at 11:48.

Similar Threads

  1. QtableWidget that don't accept drop item between rows?
    By sergiomar73 in forum General Programming
    Replies: 3
    Last Post: 15th October 2010, 21:55
  2. Replies: 1
    Last Post: 31st December 2008, 16:55
  3. Drag & Drop when parent and childs accept drops?
    By gri in forum Qt Programming
    Replies: 0
    Last Post: 17th October 2008, 09:00
  4. QGraphicsScene doesn't accept Drops
    By momesana in forum Qt Programming
    Replies: 5
    Last Post: 15th July 2007, 10:43
  5. QTableWidget QTableWidgetItem
    By TheKedge in forum Qt Programming
    Replies: 3
    Last Post: 6th September 2006, 15:03

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.