[Interest] Using qrc/qss files with Qt WASM

Esch Lorenz TU Ilmenau Lorenz.Esch at tu-ilmenau.de
Thu Jun 4 21:42:10 CEST 2020


Hi all,

I have a question regarding Qt WASM. I would like to change between different style sheets during run time in a WASM application. In the desktop version of my application I just use QFile to access the .qss file included in my .qrc file.

if(QApplication *pApp = qobject_cast<QApplication *>(QApplication::instance())) {
   QFile file;
   file.setFileName(":/styles/dark.qss");
  file.open(QFile::ReadOnly | QFile::Text);
  QTextStream stream(&file);
  pApp->setStyleSheet(stream.readAll());
}

However, under Qt WASM QFile is not supported. Instead one can use QFileDialog::getOpenFileContent to read the complete data as a QByteArray. But this prompts me with a QFileDialog first, which I do not want/need. My question: Is there a way to read from a file included in a .qrc file directly into a QByteArray? I had a look at QResource, but it seems that this class can only be used to read from an external qrc/rcc file during runtime. Any ideas?

Thanks,

Lorenz


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20200604/0d31fbc5/attachment.html>


More information about the Interest mailing list