Qt WebAssembly Widget Buttons not responding
-
Hi,
I have been dealing with a problem of qt Webassembly. Firstly i have tried to debug and run qt 6.2.4 ( webassemly 2.0.4). then qt 6.4( webassemly 3.1.14
) with corresponding versions of webassembly, however, my buttons does not respond to any kind operations. Such that i simly createed button on widget.ui, then connect it to slot on which i put qDebug() << "Test" ;. Then it is not responding niether on windows nor on linux. Could you please tell me how to solve this?? -
@SGaist Hi, well, i debuged code in desktop side as well as web side, finally i saw that printing statements are rendered on html page console, but not qt creator console. However, It is impossible to render local files and images to custom html page with webassembly?
-
To the best of my knowledge, WebAssembly does not provide support for serving server side files.
Depending on what you need these files for, you can use Qt's resource system.
-
@SGaist said in Qt WebAssembly Widget Buttons not responding:
Depending on what you need these files for, you can use Qt's resource system.
I think this is the best approach.
Other way is using QNetworkAccessManager to download the image, this has the benefit that you can download images from external websites as well, something like:
QNetworkAccessManager *manager = new QNetworkAccessManager(this); QNetworkReply *reply = manager->get(QNetworkRequest(QUrl("https://domain/image_url.jpg"))); connect(manager, &QNetworkAccessManager::finished, [&](QNetworkReply *reply){ qWarning() << "replyFinished"; QPixmap *image = new QPixmap(this); image->loadFromData(reply->readAll()); ui->label->setPixmap(QPixmap(*image)); }); connect(reply, &QIODevice::readyRead, [](){qWarning() << "reply";}); connect(reply, &QNetworkReply::errorOccurred, [](){qWarning() << "errorOccurred";});