Important: Please read the Qt Code of Conduct -

How to add .qrc and .qss files into CMake

  • Hi All,

    I have icon.qrc and Stylesheet.qss files both should come under CMake i have placed it like:

    and in the main.cpp i am reading that flex_ui_stylesheet.qss file like :

    QFile styleFile(":/flex_ui_stylesheet.qss");
    if (
    QTextStream textStream(&styleFile);
    QString styleSheet = textStream.readAll();

    but i am unble to read and get expected output , can someone suggest me where i am going wrong .

    Thanks in advance

  • Lifetime Qt Champion


    Please take a look at the CMake Manual in Qt's documentation. It shows the macros available to handle .qrc files.

    The flex_ui_stylesheet.qss has nothing to do with cmake. It should be in the resource file itself.

Log in to reply