PDA

View Full Version : QTreeWidget::setModel() - Changing the model of the QTreeWidget is not allowed.



mochen
17th March 2008, 10:21
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:


dir_model_ = new QDirModel(this);

// enable drag and drop
dir_model_->setReadOnly(false);

tree_view_ = new QTreeWidget(this);
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.

JeanC
17th March 2008, 12:27
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.

mochen
17th March 2008, 13:53
Thanks. I will correct it and retry.

I thought this was due to my typograhpic error. However it compilied without any warning.