Results 1 to 3 of 3

Thread: QTreeWidget::setModel() - Changing the model of the QTreeWidget is not allowed.

  1. #1
    Join Date
    Mar 2008
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default 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:
    Qt Code:
    1. dir_model_ = new QDirModel(this);
    2.  
    3. // enable drag and drop
    4. dir_model_->setReadOnly(false);
    5.  
    6. tree_view_ = new QTreeWidget(this);
    7. tree_view_->setModel(dir_model_);
    To copy to clipboard, switch view to plain text mode 

    I try to search Qt document and google, but I can not find any clue. How to solve this issue ?

    Thanks.
    Last edited by jpn; 17th March 2008 at 20:34. Reason: missing [code] tags

  2. #2
    Join Date
    Dec 2007
    Location
    Groningen Netherlands
    Posts
    182
    Thanks
    16
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default 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.

  3. #3
    Join Date
    Mar 2008
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Talking 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.

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.