QTreeWidget::setModel() - Changing the model of the QTreeWidget is not allowed.
Hi,
I wrote a simple Qt program, When I run the program, it told me:
QTreeWidget::setModel() - Changing the model of the QTreeWidget is not allowed.
The code just like below:
Code:
// enable drag and drop
dir_model_->setReadOnly(false);
tree_view_->setModel(dir_model_);
I try to search Qt document and google, but I can not find any clue. How to solve this issue ?
Thanks.
Re: QTreeWidget::setModel() - Changing the model of the QTreeWidget is not allowed.
I don't think you can setModel() on a QTreeWidget, but you can on a QTreeView.
There are 2 ways to use a treeview / listview etc. With the 'simple' QTreeWidget / QListWidget who have their own inner model, or through the model / view classes like for instance QTreeView / QDirModel or other models.
So just use QTreeView in stead of QTreeWidget and you're set.
Re: QTreeWidget::setModel() - Changing the model of the QTreeWidget is not allowed.
Thanks. I will correct it and retry.
I thought this was due to my typograhpic error. However it compilied without any warning.