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. QSS files - anyone got an example pls, I have QSS from Qt Creator but it is not being applied through setStyleSheet
Forum Updated to NodeBB v4.3 + New Features

QSS files - anyone got an example pls, I have QSS from Qt Creator but it is not being applied through setStyleSheet

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 6.2k 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.
  • D Offline
    D Offline
    Dolphin
    wrote on last edited by
    #1

    I can see that the file data in my QSS file is being read correctly and passed to setStyleSheet but no styling is being applied. I have not been able to find an example file to see if there is something I am missing - styles apply correctly via Qt Creator so I assume it is not syntax, unless there is something different about syntax in a file, but I cannot work that out without an example.

    The only other thing I could think was that I was loading the styles in the wrong place so I have tried everywhere I can think of (on the widget, on the window.......). Where ever I put there is no styling applied even if there is styling in the .ui file.

    1 Reply Last reply
    0
    • H Offline
      H Offline
      Hostel
      wrote on last edited by
      #2

      Example code and QSS please.

      1 Reply Last reply
      0
      • T Offline
        T Offline
        tucnak
        wrote on last edited by
        #3
        1. Bad title for the topic (it must be strict).

        2. Solution:
          @
          MainWindow::MainWindow(QObject* parent = 0) :
          QMainWindow(parent),
          ui(new Ui::MainWindow),
          {
          ui->setupUi(this);
          QFile styles(":/qss/file.qss");
          if(styles.open(QIODevice::ReadOnly)) {
          setStyleSheet(styles.readAll());
          }
          }
          @
          It must be the best way for you. And "documentation":http://qt-project.org/doc/qt-4.8/stylesheet.html of course.

        1 Reply Last reply
        0
        • D Offline
          D Offline
          Dolphin
          wrote on last edited by
          #4

          I have the code thanks, my document is loading fine but no styles get applied. What I could with is an example file - loads of example of syntax and snippets of QSS around but no actual file examples. My QSS works through QtCreator but not when loaded as a file. Without an example file I cannot work out what is wrong with mine.

          I did say please :-)

          1 Reply Last reply
          0
          • D Offline
            D Offline
            Dolphin
            wrote on last edited by
            #5

            Solved it thanks guys - file encoding was wrong :-S

            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