I can not read local file from qrc in qt5.11.2 + MSVC2017

  • Hello I used Qt 5.11.2 with MSVC2017 (only for qwebengine support). I want to load some qrc, but have error (device cannot open). And watch that file url changefrom ":/files/pagespeed.html" to windows ":\files\pagespeed.html" :c So maybe I get error from thic changes. How I can disable auto replace separator fo qrc or how I can read file from qrc? I clean all and rebuild project, but it not help me.

    I use some code:

        QFile f(":/files/pagespeed.html");
        QString html = QString(f.readAll());

    Qrc file

        <qresource prefix="/files">

    pro file

    QT       += core gui
    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets webengine webenginewidgets
    TARGET = qt5-web
    TEMPLATE = app
    CONFIG += c++11
    SOURCES += \
            main.cpp \
    HEADERS += \
    FORMS += \
    RESOURCES += \

    My error


  • Moderators

    hi @Michael-Rozshko

    qt manages the path seperator for you (internally) if you sty with the non Windows variant :)

    Anyway, did you rerun qmake after adding the file to your Qt-Ressource file ? otherwise the file will not be packed into the binary file.

    Also you can try it with the url version of the path:


  • You are right! It is my error, rebuild all project with full delete old directory and all work fine. Thanks for fast and good answer!

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.