wasm and QTableWidget
Unsolved
Qt for WebAssembly
-
I'm running Qt 6.7.2 and have a QTableWidget to show some custom QWidgets for device status dashboard. As a normal app, it work's fine. In wasm I'm not able to place any widget with setCellWidget. Is there something I have to recognize?
QLabel label(record.value("mac").toString()); label.setStyleSheet("{background: green;}"); ui->deviceTable->setCellWidget(row, column, &label);
did not show the QLabel and
ui->deviceTable->setCellWidget(row, column, new QLabel(record.value("mac").toString()));
also not. The QTableWidget is defined in the ui-file, initialized and visible. A row with three columns is also visible.
Thanks.
Dietmar -
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.