Quantcast
Channel: Qt DevNet forums: Qt Quick 1283365070**
Viewing all articles
Browse latest Browse all 4972

Filling a listView model in seperate Thread .

$
0
0
Hi guys, I am facing a problem using QML and C++. In fact I’m creating a ListView model when starting the main program and a generator of a listView to generate that list from QML:     myModel model;     Generator generator(&model);       ctxt->setContextProperty("myModel", &model);     ctxt->setContextProperty("generator", &generator);     view.setSource(QUrl("qrc:///qmlFolder/mainView.qml")); Then when the application starts I use a key event to show the listView: if (event.key === Qt.Key_Return) {    generator.generate("All"); } And the C++ part to generate the list is : void Generator::generate() {  ---             for(int i = 0 ; i < N ; i++)             {                 m_model->addModelElements("str1", "str2");             } --- } Every thing works perfect, But sometimes when the list is tooo long the annimated QML background freezes until the listView model is filled, so I have created a separete thread to handle the fill listView part and then post a signal to the main GUI thread. So in the model Class I Instantiate a New Thread and when receiving the user press button to call generate I fill ListView on the created thread. and then I have got this error : [ 0x7f1a8377e700 ] Generate ChannelList QObject::connect: Cannot queue arguments of type 'QQmlChangeSet' (Make sure 'QQmlChangeSet' is registered using qRegisterMetaType().) It is like QT does not like that I generate the ListView model from another thread and call the m_model->addModelElements() from another thread then the GUI thread ? Any Ideas Guys ??

Viewing all articles
Browse latest Browse all 4972

Trending Articles