[Solved]QObject::connect: Cannot queue arguments of type 'QQuickChangeSet'?
-
I try to make Listview with an Listmodel ( written in C++ ) and give it to QML via Contrext Propertie.
The Listmodel should be modified by an AMQP-Eventqueue.
As soon as the first event arrives I got the errormessage:
@QObject::connect: Cannot queue arguments of type 'QQuickChangeSet'
(Make sure 'QQuickChangeSet' is registered using qRegisterMetaType().)@I searched the Doc but I could not find a documentation to QQuickChangeSet
has anybody allready the same problem or does anybody know what i'm doing wrong?
The Model works fine as long i modify it by QML and not from C++.
-
No I tried a simple example ( AbstractItemModel Example from the Src-Distribution ).
The Example works allso when I implement a invokeable method and call this from qml onMouseClick.
But when i modify the example (Animal.h and Animal.cpp unchanged):
main.cpp:
@
int main(int argc, char ** argv)
{
QGuiApplication app(argc, argv);AnimalModel model; model.addAnimal(Animal("Wolf", "Medium")); model.addAnimal(Animal("Polar bear", "Large")); model.addAnimal(Animal("Quoll", "Small")); QQuickView view; view.setResizeMode(QQuickView::SizeRootObjectToView); QQmlContext *ctxt = view.rootContext(); ctxt->setContextProperty("myModel", &model);
//![0]
tThread tt; tt.addModel(&model); tt.start(); view.setSource(QUrl("qrc:view.qml")); view.show(); return app.exec();
}
@TestThread.h:
@
class tThread : public QThread
{
Q_OBJECT
public:
explicit tThread(QObject *parent = 0);
void addModel(AnimalModel * pmodel);protected:
void run();signals:
public slots:
private:
AnimalModel * _pModel;};@
TestThread.cpp:
@tThread::tThread(QObject *parent) :
QThread(parent)
{
this->setTerminationEnabled(true);
}void tThread::addModel(AnimalModel *pmodel)
{
this->_pModel = pmodel;
}void tThread::run()
{
while(true) {
sleep(2);
std::cout << "Thread: Model has " << _pModel->rowCount() << " items before append" << std::endl;
_pModel->addAnimal(Animal("Dog","medium"));
std::cout << "Thread: Model has " << _pModel->rowCount() << " items after append" << std::endl;
}
}@The Items inserted in the Model, but I got no update to the List in the qml.
I only get the Message:@QObject::connect: Cannot queue arguments of type 'QQuickChangeSet'
(Make sure 'QQuickChangeSet' is registered using qRegisterMetaType().)@What doing I wrong?????
-
I have now found a documentation about this.
"QT-Doc:":http://qt-project.org/doc/qt-5.0/qtcore/queuedcustomtype.html
I have to use
Q_DECLARE_METATYPE,
qRegisterMetaTypeand don't insert it into the model, i have to work with signals and slots.
now it works.
-
I also have a problem like you had
When I send modelReset signal, insert rows for the first time, I get that error message, and then my qml list view ignores any changescan you please tell what you had to do to make your model work
AFAIK QQuickChangeSet is QtQuick private class, did you explicitly register it ? -
Hi DRemesov,
To fix this prblem,you must register the custom type with qRegisterMetaType<MyType>("MyType").This artical may help you.
http://blog.ayoy.net/2009/2/15/registering-custom-types -
Right solution is to send an signal from worker thread to UI thread. See https://stackoverflow.com/a/43686691/1733955