Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [RESOLVED] StyleSheet file... it's possible?
Qt 6.12 LTS is out! See what's new in the release blog

[RESOLVED] StyleSheet file... it's possible?

Scheduled Pinned Locked Moved General and Desktop
12 Posts 3 Posters 9.4k 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
    dcbasso
    wrote on last edited by
    #3

    Thanks Andre!

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #4

      @
      QFile fileDark(":/qss/vc2.qss");
      fileDark.open(QFile::ReadOnly);
      app.setStyleSheet(fileDark.readAll());
      @

      qss is a css file, it is embedded as qresource

      1 Reply Last reply
      0
      • A Offline
        A Offline
        andre
        wrote on last edited by
        #5

        [quote author="broadpeak" date="1347370429"]@
        ...[/quote]
        You're spoiling all the "this is left as an excersise for the reader" fun! ;-)

        1 Reply Last reply
        0
        • D Offline
          D Offline
          dcbasso
          wrote on last edited by
          #6

          Thanks broadpeak.
          I'm already using here, with .css and qresource. Works very well.

          Thanks.

          1 Reply Last reply
          0
          • ? Offline
            ? Offline
            A Former User
            wrote on last edited by
            #7

            [quote author="Andre" date="1347370510"][quote author="broadpeak" date="1347370429"]@
            ...[/quote]
            You're spoiling all the "this is left as an excersise for the reader" fun! ;-)

            [/quote]

            Ahhhhhhhhhh! Sorry :) I will never.... :)

            1 Reply Last reply
            0
            • A Offline
              A Offline
              andre
              wrote on last edited by
              #8

              By the way: note that your (broadpeak) method has a potential danger. You implicitly cast a QByteArray to a QString: QFile::readAll() returns a QByteArray, while setStyleSheet takes a QString. That means that you assume that the .css file will be ASCII (see the docs for QString). That might or might not be a valid assumption... I prefer to use a [[doc:QTextStream]] to read a text file instead.

              1 Reply Last reply
              0
              • D Offline
                D Offline
                dcbasso
                wrote on last edited by
                #9

                I use to read some files like the "broadpeak" code!
                Nothing wrong at all, but I will read about the QTextStream!

                Thanks Andre.

                1 Reply Last reply
                0
                • ? Offline
                  ? Offline
                  A Former User
                  wrote on last edited by
                  #10

                  [quote author="Andre" date="1347371510"]...that you assume that the .css file will be ASCII ... That might or might not be a valid assumption... I prefer to use a [[doc:QTextStream]] to read a text file instead.
                  [/quote]

                  Yes, of course, you are right (as usual :))!
                  But I always use simple ASCII editor for css editing, because I never have special character in my qss file.

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    andre
                    wrote on last edited by
                    #11

                    Well, for instance, the file names for images or object names for widgets may contain unicode characters, especially for developers from non-English speaking countries...

                    1 Reply Last reply
                    0
                    • D Offline
                      D Offline
                      dcbasso
                      wrote on last edited by
                      #12

                      Well, I'm from Brazil and here we use the special chars (çãáâü....) but in source codes and etc... we avoid them... or I void this chars.

                      But for safe reasons appears to me better use the "QTextStream".

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