Results 1 to 4 of 4

Thread: QTableWidget - problem when editing multiple items

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2011
    Posts
    3
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTableWidget - problem when editing multiple items

    Thanks norobro, it works fine and I'm using it.
    I have tested another way by making this little "good blood" hack:

    Qt Code:
    1. class MyTableWidgetItem : public QTableWidgetItem
    2. {
    3. public:
    4. explicit MyTableWidgetItem(const QString & text, int type = Type) : QTableWidgetItem(text, type) {}
    5.  
    6. virtual void setData(int role, const QVariant &value)
    7. {
    8. if (QAbstractTableModel *model = (this->tableWidget() ? qobject_cast<QAbstractTableModel*>(this->tableWidget()->model()) : 0)) {
    9. model->blockSignals(true);
    10. QVariant nullValue;
    11. QTableWidgetItem::setData(role,nullValue);
    12. model->blockSignals(false);
    13. }
    14. QTableWidgetItem::setData(role,value);
    15. }
    16. };
    17.  
    18. //--
    19.  
    20. QTableWidgetTest::QTableWidgetTest(QWidget *parent, Qt::WFlags flags)
    21. : QDialog(parent, flags)
    22. {
    23. ui.setupUi(this);
    24.  
    25. int value= 0;
    26. for (int row= 0; row < table->rowCount(); row++) {
    27. for (int col= 0; col < table->columnCount(); col++) {
    28. QTableWidgetItem *item= new MyTableWidgetItem(QString::number(value));
    29. table->setItem(row,col,item);
    30. value++;
    31. }
    32. }
    33.  
    34. connect(ui.tableWidget, SIGNAL(itemChanged(QTableWidgetItem*)), this, SLOT(multipleItemsChanged(QTableWidgetItem*)));
    35. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Oct 2011
    Posts
    3
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default [Solved] Re: QTableWidget - problem when editing multiple items

    [Solved]
    this thread is solved

Similar Threads

  1. Replies: 2
    Last Post: 21st September 2011, 06:32
  2. QT Tree Widget - Issues editing items
    By epsilonorion in forum Qt Programming
    Replies: 0
    Last Post: 7th July 2011, 15:19
  3. Problem loading multiple GIF images in qtablewidget.
    By sanket.mehta in forum Qt Programming
    Replies: 2
    Last Post: 13th September 2010, 10:31
  4. Problem editing TreeWidget items
    By Moezzie in forum Qt Programming
    Replies: 3
    Last Post: 15th December 2007, 21:22
  5. QTableWidget editing question
    By Trasmeister in forum Qt Programming
    Replies: 1
    Last Post: 20th September 2006, 18:46

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
  •  
Qt is a trademark of The Qt Company.