Note that there are some explanatory texts on larger screens.

plurals
  1. POQItemDelegate setModelData in QTreeWidget is not called
    primarykey
    data
    text
    <p>I am trying to set delegate to my QTreeWidget. The problem is that delegate setModelData is never called. createEditor and setEditorData are called.</p> <p>Since the editor that I create is simple QLineEdit, commitData() signal doesn't have to be emitted. Also I tried to emit this signal just in case is needed , when editLine editingFinished() was emitted, but that doesn't solve the problem. As I understand documentaion say that for simple widgets like QLineEdit setModelData should be called without emitting commitData signal, so the following code should work :</p> <pre><code>MyDlg::MyDlg() { mTreeWdg-&gt;setItemDelegate(new TestDelegate( this )); } MyDlg::OnTreeItemDoubleCliked(QTreeeWidget* item,int column) { if(column != 1) return; item-&gt;setFlags(Qt::ItemIsEditable); mTreeWdg-&gt;editItem(item,column); } TestDelegate::TestDelegate(QObject *parent ) :QItemDelegate(parent) { } QWidget* TestDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &amp;option, const QModelIndex &amp;index) const { if(index.column() == 1) // value column { QLineEdit* edit = new QLineEdit(parent); return edit; } else return 0; // no editor attached } void TestDelegate::setEditorData(QWidget *editor, const QModelIndex &amp;index) const { if(index.column() == 1) { QLineEdit* edit = static_cast&lt;QLineEdit*&gt; (editor); edit-&gt;setText("damn"); } } void TestDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,const QModelIndex &amp;index) { if(index.column()!= 1) return; } void TestDelegate::updateEditorGeometry(QWidget *editor,const QStyleOptionViewItem &amp;option, const QModelIndex &amp;index) const { editor-&gt;setGeometry(option.rect); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload