Where is ModelTest?



  • Hi,

    Qt used to have a testing framework for model/view models. It is still described in http://doc.qt.io/qt-5/modelview.html#3-5-debugging-with-modeltest. Hoever its repository seems to have disappeared. Where can I find it? If it was taken down, how are you supposed to do quality assurance on models nowadays?

    Thanks!


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Do you mean that one that is linked in the wiki page ?


  • Lifetime Qt Champion

    Which can be find here for Qt 5



  • @SGaist Yes! That is the one. The tutorial refers to Qt Labs, which sent me in the wrong direction.

    That repo seems to be just for Qt4, and limited to security fixes only. But since the tutorial is part of Qt 5.9 also, where do I go with my patches to make it work for Qt5? I have two: the first one eliminates a deprecated call to QAbstractItemModel::reset(), the second one reintroduces the .pri file referenced in the wiki. They work for Qt 5.6, I'm going to test them for Qt 5.9.

    From 0edb1bb79327fb7ebd21a3a7b17774bc91ebb322 Mon Sep 17 00:00:00 2001
    From: Bastiaan Veelo <Bastiaan@Veelo.net>
    Date: Tue, 8 Mar 2016 11:06:25 +0100
    Subject: [PATCH 2/2] Eliminate deprecated call to 
     QAbstractItemModel::reset().
    
    Change-Id: Iea8e7c89431eb8fb045dcc860f27ab835708a145
    ---
     tests/auto/other/modeltest/dynamictreemodel.cpp | 30 ++-----------------------
     tests/auto/other/modeltest/dynamictreemodel.h   | 19 +---------------
     2 files changed, 3 insertions(+), 46 deletions(-)
    
    diff --git a/tests/auto/other/modeltest/dynamictreemodel.cpp b/tests/auto/other/modeltest/dynamictreemodel.cpp
    index 6a75a3d..32bbb6c 100644
    --- a/tests/auto/other/modeltest/dynamictreemodel.cpp
    +++ b/tests/auto/other/modeltest/dynamictreemodel.cpp
    @@ -283,6 +283,7 @@ void ModelMoveCommand::emitPostSignal()
         m_model->endMoveRows();
     }
     
    +
     ModelResetCommand::ModelResetCommand(DynamicTreeModel* model, QObject* parent)
       : ModelMoveCommand(model, parent)
     {
    @@ -302,38 +303,11 @@ bool ModelResetCommand::emitPreSignal(const QModelIndex &srcParent, int srcStart
         Q_UNUSED(destParent);
         Q_UNUSED(destRow);
     
    -    return true;
    -}
    -
    -void ModelResetCommand::emitPostSignal()
    -{
    -    m_model->reset();
    -}
    -
    -ModelResetCommandFixed::ModelResetCommandFixed(DynamicTreeModel* model, QObject* parent)
    -  : ModelMoveCommand(model, parent)
    -{
    -
    -}
    -
    -ModelResetCommandFixed::~ModelResetCommandFixed()
    -{
    -
    -}
    -
    -bool ModelResetCommandFixed::emitPreSignal(const QModelIndex &srcParent, int srcStart, int srcEnd, const QModelIndex &destParent, int destRow)
    -{
    -    Q_UNUSED(srcParent);
    -    Q_UNUSED(srcStart);
    -    Q_UNUSED(srcEnd);
    -    Q_UNUSED(destParent);
    -    Q_UNUSED(destRow);
    -
         m_model->beginResetModel();
         return true;
     }
     
    -void ModelResetCommandFixed::emitPostSignal()
    +void ModelResetCommand::emitPostSignal()
     {
         m_model->endResetModel();
     }
    diff --git a/tests/auto/other/modeltest/dynamictreemodel.h b/tests/auto/other/modeltest/dynamictreemodel.h
    index 8fd2a54..f6d6aa7 100644
    --- a/tests/auto/other/modeltest/dynamictreemodel.h
    +++ b/tests/auto/other/modeltest/dynamictreemodel.h
    @@ -88,7 +88,6 @@ private:
       friend class ModelInsertCommand;
       friend class ModelMoveCommand;
       friend class ModelResetCommand;
    -  friend class ModelResetCommandFixed;
       friend class ModelChangeChildrenLayoutsCommand;
     
     };
    @@ -163,7 +162,7 @@ protected:
     };
     
     /**
    -  A command which does a move and emits a reset signal.
    +  A command which does a move and emits a beginResetModel and endResetModel signals.
     */
     class ModelResetCommand : public ModelMoveCommand
     {
    @@ -178,22 +177,6 @@ public:
     
     };
     
    -/**
    -  A command which does a move and emits a beginResetModel and endResetModel signals.
    -*/
    -class ModelResetCommandFixed : public ModelMoveCommand
    -{
    -  Q_OBJECT
    -public:
    -  ModelResetCommandFixed(DynamicTreeModel* model, QObject* parent = 0);
    -
    -  virtual ~ModelResetCommandFixed();
    -
    -  virtual bool emitPreSignal(const QModelIndex &srcParent, int srcStart, int srcEnd, const QModelIndex &destParent, int destRow);
    -  virtual void emitPostSignal();
    -
    -};
    -
     class ModelChangeChildrenLayoutsCommand : public ModelChangeCommand
     {
       Q_OBJECT
    -- 
    1.9.5.msysgit.0
    
    From e88b55e028630a8e41d2e800461d962a87e91c7e Mon Sep 17 00:00:00 2001
    From: Bastiaan Veelo <Bastiaan@Veelo.net>
    Date: Tue, 8 Mar 2016 11:05:46 +0100
    Subject: [PATCH 1/2] Reintroduce .pri to allow client code do model testing.
     This was present in Qt4.
    
    Change-Id: I65071a42e68068378836b7e8dcb99d7b208b72d1
    ---
     tests/auto/other/modeltest/modeltest.pri | 11 +++++++++++
     1 file changed, 11 insertions(+)
     create mode 100644 tests/auto/other/modeltest/modeltest.pri
    
    diff --git a/tests/auto/other/modeltest/modeltest.pri b/tests/auto/other/modeltest/modeltest.pri
    new file mode 100644
    index 0000000..988b9da
    --- /dev/null
    +++ b/tests/auto/other/modeltest/modeltest.pri
    @@ -0,0 +1,11 @@
    +INCLUDEPATH += $$PWD
    +DEPENDPATH += $$PWD
    +
    +SOURCES         +=  $$PWD/tst_modeltest.cpp \
    +		    $$PWD/modeltest.cpp \
    +		    $$PWD/dynamictreemodel.cpp
    +HEADERS         +=  $$PWD/modeltest.h \
    +		    $$PWD/dynamictreemodel.h
    +
    +
    +
    -- 
    1.9.5.msysgit.0
    


  • @SGaist said in Where is ModelTest?:

    Which can be find here for Qt 5

    Oh thanks, somehow your second post did not show. Thanks a lot.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.