Important: Please read the Qt Code of Conduct -

How to avoid a QTreeView -"setUpdatesEnabled(false)" from erasing itself before restore with "setUpdatesEnabled(true)"

  • I use a QTreeView with QStandartItemModel,I trigger a Dlg that will change the QStandartItemModel underling structure.
    So I need temporarily prevent view to update which in turn call QStandartItemModel 's index() or sth need to read data from the underling the structure .

    But when I call QTreeView -"setUpdatesEnabled(false)" before the DLg.exec(). the View is erased?

    how can I stop view to update but not erase it?


  • I have solved it myself.
    Thanks any way!

  • Can you post the solution? Otherwise this thread is useless.

  • OK!
    @m_deviceView->setAttribute(Qt::WA_OpaquePaintEvent, !bEnable);@
    I previous use:

    Like Mentioned above,@setUpdatesEnabled(bEnable)@May suit the situation for a short period of time only(like writed in QT document)

    But In my case,I want the Dlg.exec() waiting the user may longer time interaction until restore the QTreeVIew update.

    So May my solution is not ideal but enough for me .

    If you have good or more reasonable solution ,then let me know.

    Thanks in advance!

Log in to reply