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. setStylesheet = Qss file

setStylesheet = Qss file

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 783 Views
  • 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.
  • K Offline
    K Offline
    Kris Revi
    wrote on last edited by
    #1
        QFile file(":/theme/dark.qss");
        file.open(QFile::ReadOnly);
        QString styleSheet = QLatin1String(file.readAll());
        a.setStyleSheet(styleSheet);
    

    gives me

    QIODevice::read (QFile, ":\theme\dark.qss"): device not open
    

    w0000t....

    JonBJ 1 Reply Last reply
    0
    • K Kris Revi
          QFile file(":/theme/dark.qss");
          file.open(QFile::ReadOnly);
          QString styleSheet = QLatin1String(file.readAll());
          a.setStyleSheet(styleSheet);
      

      gives me

      QIODevice::read (QFile, ":\theme\dark.qss"): device not open
      

      w0000t....

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @Kris-Revi
      QFile::open() returns a bool so you can test whether it has succeeded or not. Clearly it has not here.

      K 1 Reply Last reply
      0
      • JonBJ JonB

        @Kris-Revi
        QFile::open() returns a bool so you can test whether it has succeeded or not. Clearly it has not here.

        K Offline
        K Offline
        Kris Revi
        wrote on last edited by Kris Revi
        #3

        @JonB so i added this

            QFile ssf(":/theme/dark.qss");
        
            if( ssf.exists() )
            {
                qDebug() << "Stylesheet does exists";
            }
            if( ssf.open(QFile::ReadOnly) )
            {
                qDebug() << "File is opened for read!";
            }
        
            QString styleSheet = QLatin1String(ssf.readAll());
            a.setStyleSheet(styleSheet);
        

        but none of them prints :/

        eyllanescE 1 Reply Last reply
        0
        • K Kris Revi

          @JonB so i added this

              QFile ssf(":/theme/dark.qss");
          
              if( ssf.exists() )
              {
                  qDebug() << "Stylesheet does exists";
              }
              if( ssf.open(QFile::ReadOnly) )
              {
                  qDebug() << "File is opened for read!";
              }
          
              QString styleSheet = QLatin1String(ssf.readAll());
              a.setStyleSheet(styleSheet);
          

          but none of them prints :/

          eyllanescE Offline
          eyllanescE Offline
          eyllanesc
          wrote on last edited by
          #4

          @Kris-Revi So that file doesn't exist. Show the .pro and .qrc

          If you want me to help you develop some work then you can write to my email: e.yllanescucho@gmal.com.

          K 1 Reply Last reply
          0
          • eyllanescE eyllanesc

            @Kris-Revi So that file doesn't exist. Show the .pro and .qrc

            K Offline
            K Offline
            Kris Revi
            wrote on last edited by Kris Revi
            #5

            @eyllanesc

            86831187-d2c2-44e5-a893-6e747724d57e-image.png

            EDIT:

            i just ran qmake and now it fixed itself...

            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