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

  • 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.

  • Example code and QSS please.

    1. Bad title for the topic (it must be strict).

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

  • 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 :-)

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

Log in to reply

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