Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Modeltest from official Qt5 doc is definitly not for Qt5, and testmodel find on git for qt5 not works too...
Qt 6.11 is out! See what's new in the release blog

Modeltest from official Qt5 doc is definitly not for Qt5, and testmodel find on git for qt5 not works too...

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • jerome_isAviableJ Offline
    jerome_isAviableJ Offline
    jerome_isAviable
    wrote on last edited by
    #1

    someone know a serious modeltest who really works ?
    this from Qt5 doc is not for qt5 (i don't know why it is inside this doc... serve nothing)
    and this one from git (seems to be for Qt5 but 2 years old...):
    https://github.com/bruceoutdoors/Intro-Design-Patterns-Cpp-Qt5/tree/master/libs/modeltest

    don't woks too: compil well but have a segment fault error directly at the start of first function...

    is there a modeltest who really works ? or do you know why no one works ?
    (maybe you can test by yourself)

    1 Reply Last reply
    0
    • W Offline
      W Offline
      wydesenej
      wrote on last edited by
      #2

      Hi,

      I had same problem.

      I modified modeltest and succesfully compiled with Qt5.4.
      I must warn that my modifications of modeltest is maybe not in consistency with original purpouse of this project: I dont want to use this project in unit testing and i want to see all mistakes at runtime (see below in point 3).

      What I did:

      1. Replace qVariantCanConvert with QVariant::canConvert (according to http://qt-project.org/wiki/Transition_from_Qt_4.x_to_Qt5)

      @
      if ( variant.isValid() ) myVERIFY( variant.canConvert(QMetaType::QString));
      @
      etc.

      1. Add function DynamicTreeModel::reset() which missing in QAbstractItemModel in latest Qt versions.
        @
        void reset()
        {
        beginResetModel();
        endResetModel();
        }
        @

      2. Replace QVERIFY and QCOMPARE with my own macros (To report failed tests at runtime).

      @
      #define myVERIFY(statement)
      if(!(statement)) { qCritical() << "ModelTest myVERIFY failed at line " << LINE; return; }

      #define myCOMPARE(actual, expected)
      if((actual)!=(expected)) { qCritical() << "ModelTest myCOMPARE failed at line " << LINE << "(actual="<< (actual) << ";expected=" << (expected) << ")"; return; }
      @

      I am realy not sure if I did all theese changes right so any prompts are welcome...

      1 Reply Last reply
      0
      • jerome_isAviableJ Offline
        jerome_isAviableJ Offline
        jerome_isAviable
        wrote on last edited by
        #3

        thanks for answer wydesenej
        i try to download the files from same link than before without any succes due ti the page has bben removed (i hope she will go back soon).
        So maybe you have a git repository to provide the code with or an other idea ?

        But anyway, maybe someone see your post and do something at the same time i try to have it.

        thanks again for fix.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved