c++ - QtQuick, QThread, and signals integration -
i have simple application can seen @ github: https://github.com/lejmr/qtquicktest
what realized when cppslot called , takes long finish gui gets irresponsible. therefore, decided initiate new thread when calling cppslot function such updated connect section to:
qthread* thread = new qthread; analyzesignal.movetothread(thread); qobject::connect(item, signal(doanalyzesignal(qstring,qstring,qstring,qstring)), &analyzesignal, slot(cppslot(qstring,qstring,qstring,qstring))); thread->start();
however, if error:
qobject: cannot create children parent in different thread.
(parent qquicktextdocumentwithimageresources(0x2ae4de0)
, parent's thread qthread(0x20081e0)
, current thread qthread(0x2302730)
i think caused https://github.com/lejmr/qtquicktest/blob/master/main.cpp#l15 propagate wrong pointer (onto original thread, signal initiated different thread).
i tried whole bunch of things, haven't managed succeed.
the goal write output of called program textfield in gui instead of putting console.
you trying thread right? connect signal slot calls function using qtconcurrent::run
qtconcurrent::run(this, &whateveryourclassiscalled::cppslot, param1, param2, etc);
Comments
Post a Comment