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. The text file from resource in Qt 4.8 not open?

The text file from resource in Qt 4.8 not open?

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 1.0k 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.
  • MhM93M Offline
    MhM93M Offline
    MhM93
    wrote on last edited by A Former User
    #1

    I have a file the contain the project style sheet and I added it to my Resource file.
    I use this code to open the style sheet. but I think this code could not open the file:

    QFile File(":/style.qss");
         File.open(QFile::ReadOnly);
    
         QString StyleSheet = QLatin1String(File.readAll());
        qApp->setStyleSheet(StyleSheet);  
    I used qt4.8 . the images in this resource is loaded but this file could not open to apply style sheet to my project.  
    
    How can I apply style sheet to my project?
    
    thank you.
    

    H.Ghassami

    1 Reply Last reply
    0
    • Pradeep KumarP Offline
      Pradeep KumarP Offline
      Pradeep Kumar
      wrote on last edited by
      #2

      Hi,

      Why dont you use a common class for Stylesheet for your entire application,
      Name the class as stylesheetCommon.h
      define the variables inside it

      For Ex:

      #define stylesheetButton "background-color:#000000 ;color: #FFFFFF;font-size: 40px;"

      use the variable

      qApp->setStyleSheet(stylesheetButton);

      Pradeep Kumar
      Qt,QML Developer

      1 Reply Last reply
      3
      • MhM93M Offline
        MhM93M Offline
        MhM93
        wrote on last edited by
        #3

        thanks. it solved.

        H.Ghassami

        1 Reply Last reply
        0
        • Pradeep KumarP Offline
          Pradeep KumarP Offline
          Pradeep Kumar
          wrote on last edited by Pradeep Kumar
          #4

          What was the issue @MhM93
          ?
          can you share the solution.
          using resource file?

          Thanks,

          Pradeep Kumar
          Qt,QML Developer

          1 Reply Last reply
          0
          • MhM93M Offline
            MhM93M Offline
            MhM93
            wrote on last edited by
            #5

            your solution is nice but i find my problem in my code. after delete the extra code it works fine and the main code does not have any problem.
            Your solution is also a second way to set stylesheet for at app.

            H.Ghassami

            1 Reply Last reply
            1

            • Login

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