I'am trying to call asynchrone function like slot but when i click on the button nothing happen.
Code:
connect(ui->Button1, SIGNAL(clicked()), this, SLOT(QtConcurrent::run(func1)));
func is declared in private slot.
When i call function normally, everything work nice but the app is frozen during some time until the function completes.
connect(ui->Button1, SIGNAL(clicked()), this, SLOT(func1()));
connecthas implicit Qt::ConnectionType parameter. It will be defined asQt::QueuedConnectionwhen sender and receiver are in different threads. You can useQObject::moveToThreadto move worker to another thread.If for some reason you want use
QtConcurrent::runhere - you can use it insidefunc1implementation.Check both versions:
P.S. Strongly suggest to stop using SIGNAL and SLOT macros, that's Qt4 way to connect. More info on this topic here.