c++ - QObject::moveToThread: Widgets cannot be moved to a new thread -
my ide qt 5.0.1, platform linux
i have problem set widgets window.(my opinion)
this main.cpp->
int main(int argc, char *argv[]) { qapplication a(argc, argv); qthread cthread; mainwindow w; w.dosetup(cthread); w.movetothread(&cthread); cthread.start(); if(cthread.isrunning()) { qdebug() << " thread running..."; } w.show(); return a.exec(); }
this dosetup() method->
void mainwindow::dosetup(qthread &mainthread) { qobject::connect(&mainthread, &qthread::started, this, &mainwindow::activeloopmainc); }
i checked signal-slot mechanism , works.
slot method->
void mainwindow::activeloopmainc() { qdebug() << " signal-slot structure working successfully.."; mainthreadproc((void*)(instaddr)); }
i call function main.c slot method.
in debugging there no problem working codes. window blank. there frame.
i receive error message: qobject::movetothread: widgets cannot moved new thread
how can solve problem?
thank in advance answers.
you can't move widgets thread - in order keep user interface responsive, qt needs gui work inside main thread.
if have background work do, move background worker other thread, , not user interface.
Comments
Post a Comment