Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Use same StyleSheets in build and runtime
Forum Updated to NodeBB v4.3 + New Features

Use same StyleSheets in build and runtime

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 708 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    moravas
    wrote on last edited by
    #1

    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?

    Regards,
    Norbert

    1 Reply Last reply
    0
    • S Offline
      S Offline
      steno
      wrote on last edited by
      #2

      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();
      
          styleSheet.close();
          setStyleSheet(styleSheetContent);
      

      }
      @

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved