Ubuntu 16.04, Qt 5.6.
There is a slot, it is addressed from the streams. It is necessary to make a turn. How can this be implemented?
//action_user.cpp void Action_user::Action_route() { DB_connect connectDB; connect(this, SIGNAL(AddUser(int, QStringList)), &connectDB, SLOT(AddDB(int, QStringList))); connect(this, SIGNAL(AddCargo(int, QStringList)), &connectDB, SLOT(AddDB(int, QStringList))); switch (route_signal) { case 1: emit AddUser(this->route_signal, parametrList); break; case 2: emit AddCargo(this->route_signal, parametrList); break; default: break; } } //db_connect.cpp void DB_connect::AddDB(int route, QStringList parametrList) { switch (route) { case 1: addUser(parametrList); break; case 2: addCargo(parametrList); break; default: break; } } void addUser (QStringList parametrList) { // Запись данных в БД }
Action_route()andAddDBslot between themselves in identical threads are functioning. In this case, specify theQt::QueuedConnectionflag explicitly forconnect(). - alexis031182