Results 1 to 2 of 2

Thread: Problem with updating QTreeView with QAbstractITemModel

  1. #1
    Join Date
    Apr 2021
    Posts
    27
    Thanks
    5

    Default Problem with updating QTreeView with QAbstractITemModel

    Currently, there is a problem with line number 5, QT doesn't allow to change the QTreeWidget model.

    Is there a view to fixing this problem? instead of using QtreeView.


    Qt Code:
    1. QAbstractItemModel * sourceModel;
    2. sourceModel = ui->treeWidget->model();
    3. proxyModel->setSourceModel(sourceModel);
    4. ui->treeWidget->QTreeWidget::setModel(proxyModel);
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Bremen, Germany
    Posts
    554
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem with updating QTreeView with QAbstractITemModel

    You must not change the model of a QTree/Table/ListWidget - if you want to set a custom model, use the corresponding QTree/Table/ListView classes.
    You don't need a QSortFilterProxyModel for a QTreeWidget. See the documentation how to achieve sorting there: https://doc.qt.io/qt-5/qtreewidgetitem.html#operator-lt

Similar Threads

  1. Replies: 1
    Last Post: 27th April 2021, 17:58
  2. Updating QAbstractItemModel with new records
    By psih128 in forum Qt Programming
    Replies: 0
    Last Post: 10th May 2010, 02:02
  3. QTreeView with QAbstractItemModel
    By Fletcher in forum Qt Programming
    Replies: 4
    Last Post: 11th December 2009, 00:02
  4. Need help Updating QTreeView model (QAbstractItemModel)
    By iraytrace in forum Qt Programming
    Replies: 1
    Last Post: 26th October 2009, 23:49
  5. Need help with QTreeView/QAbstractItemModel
    By Valheru in forum Qt Programming
    Replies: 5
    Last Post: 28th August 2006, 16:09

Tags for this Thread

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.