Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for WebAssembly
  4. wasm and QTableWidget
Qt 6.11 is out! See what's new in the release blog

wasm and QTableWidget

Scheduled Pinned Locked Moved Unsolved Qt for WebAssembly
2 Posts 1 Posters 837 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    Erni42 0
    wrote on last edited by Erni42 0
    #1

    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

    1 Reply Last reply
    0
    • E Offline
      E Offline
      Erni42 0
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      1

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved