From 645e73802a41feeb380ec78fdd19092e19f05f15 Mon Sep 17 00:00:00 2001 From: Sebastian Lohff Date: Thu, 30 Jun 2022 23:19:57 +0200 Subject: [PATCH] qt5 conv: replace reset() for models In qt5 reset() is no longer available for models, instead one should call beginResetModel(), then reset the model data and then call endResetModel(). See https://doc.qt.io/qt-5/qabstractitemmodel-obsolete.html#reset --- catalogmodel.cpp | 4 ++-- chaptermodel.cpp | 6 ++++-- questionmodel.cpp | 6 ++++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/catalogmodel.cpp b/catalogmodel.cpp index cd8cd51..60942aa 100644 --- a/catalogmodel.cpp +++ b/catalogmodel.cpp @@ -45,9 +45,9 @@ void CCatalogModel::onLanguageChanged() void CCatalogModel::setModelData (CCatalog *pCatalog) { - reset(); + beginResetModel(); m_pCatalog = pCatalog; - reset(); + endResetModel(); } int CCatalogModel::columnCount (const QModelIndex& parent) const diff --git a/chaptermodel.cpp b/chaptermodel.cpp index 31b1673..b1f8150 100644 --- a/chaptermodel.cpp +++ b/chaptermodel.cpp @@ -45,16 +45,18 @@ void CChapterModel::onLanguageChanged() void CChapterModel::clear() { + beginResetModel(); m_listChapter.clear(); m_pCatalog = 0; - reset(); + endResetModel(); } void CChapterModel::setModelData (CCatalog *pCatalog, QList listChapter) { + beginResetModel(); m_listChapter = listChapter; m_pCatalog = pCatalog; - reset(); + endResetModel(); } int CChapterModel::columnCount (const QModelIndex & parent) const diff --git a/questionmodel.cpp b/questionmodel.cpp index 23417ec..b049e38 100644 --- a/questionmodel.cpp +++ b/questionmodel.cpp @@ -40,14 +40,16 @@ void CQuestionModel::onLanguageChanged() void CQuestionModel::clear() { + beginResetModel(); m_pChapter=0; - reset(); + endResetModel(); } void CQuestionModel::setModelData (CChapter *pChapter) { + beginResetModel(); m_pChapter = pChapter; - reset(); + endResetModel(); } int CQuestionModel::columnCount (const QModelIndex & parent) const