I had the constructor of the QWidget sub class inside a lambda construct and was not able to make it work. Now I call a function of the owner class from the lambda and everything works fine.
old code:
connect(m_database, &WsDatabase::devicesCollected, this, [&](QJsonArray data){
disconnect(m_database, &WsDatabase::devicesCollected, this, nullptr);
for(const QJsonValue &value : data) {
DeviceWidget *widget = new DeviceWidget(m_user, this);
ui->deviceTable->setCellWidget(row, column, widget);
column++;
if (column == 3) {
row++;
column = 0;
}
}
});
m_database->getData(
"select * from devices",
m_user.userRole == WsServ::UserRoles::SuperAdmin ? "" : QString(" id_usergroup = %1").arg(m_idSelectedUserGroup),
WsServ::Devices
);
new code:
connect(m_database, &WsDatabase::devicesCollected, this, [this](QJsonArray data){
disconnect(m_database, &WsDatabase::devicesCollected, this, nullptr);
deviceEntryReady(data);
});
A sample app from scratch didn't had the problem.