Issues compiling modeltest with Qt 5.1
-
I've just finished (kinda) working on my QAbstractItemModel subclass, trying to verify it with "modeltest":http://qt-project.org/wiki/Model_Test. After editing some more obvious errors I'm left with one compilation error in method ModelResetCommand::emitPostSignal(), which looks like this:
@void ModelResetCommand::emitPostSignal()
{
m_model->reset();
}@The error is 'reset' is not a member of 'DynamicTreeModel', where QAbstractItemModel is a QAbstractItemModel subclass that does indeed have no reset() method. Ideas anyone?
-
Sorry, but what is your point? If m_model does not have a function "reset()", you cannot call it. It just will not work.
If m_model is secretly of a different kind that has access to a reset()-function, cast it to that kind before calling the function.
-
The point is this is a module from Qt repository that's supposed to work out of the box.
-
What kind of object is m_model?
-
DynamicTreeModel, which is a subclass of QAbstractItemModel. Source code: https://qt.gitorious.org/qt/qt/source/57756e72adf2081137b97f0e689dd16c770d10b1:tests/auto/modeltest
-
I do not see the connection between your problem and the Model_Test. In your very own slot (right?) you are requesting a function of an object created by you, and that function is implemented at no point. Did you maybe mean "resetInternalData":http://qt-project.org/doc/qt-5.1/qtcore/qabstractitemmodel.html#resetInternalData ? If not, you will have to implement a function called "reset" or nothing will happen.
If I understand correctly, the Model_Test will abort your application if some kind of error pops up during runtime. If the application doesn't compile in the first place, the error should be found somewhere else.
-
No. What I'm talking about is an error compiling modeltest.cpp from the repository.
-
Ok, it seems I misunderstood you, sorry.
"reset()":http://qt-project.org/doc/qt-4.8/qabstractitemmodel.html#reset has been a member of QAbstractItemModel before Qt 5 and was then moved to the "Compatibility Members":http://qt-project.org/doc/qt-5.1/qtcore/qabstractitemmodel-compat.html .
It seems there is no single replacement for reset(), and therefore you may have found a bug, depending on where you dug up your line of code. -
Fair enough, I guess modeltest hasn't been adapted to Qt 5 yet. Thanks.
-
Hi,
You could have a look at the "bug report system":http://bugreports.qt-project.org to see whether there's already something about this. If not, create a new bug report with a minimal example that reproduces the problem.