Qt World Summit: Register Today!

Use same StyleSheets in build and runtime

  • Hi Folks,

    I have a relative complex UI and I would like customize it by .css or .qss file. The problem is the following: How can I set a given .css file in the UI editor of the Qt Creator at any widgets styleSheet property and use this file at runtime as well?


  • The stylesheet property in the designer takes actual css, not a file name.

    QFile styleSheet("myStyleSheet.css");
    if ( styleSheet.open( QFile::ReadOnly ) )
    QTextStream textStream( &styleSheet );

        QString styleSheetContent = textStream.readAll();


Log in to reply