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. Problem with style sheet fonts
Forum Updated to NodeBB v4.3 + New Features

Problem with style sheet fonts

Scheduled Pinned Locked Moved Unsolved General and Desktop
10 Posts 3 Posters 1.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.
  • W Offline
    W Offline
    Will_Craig
    wrote on last edited by Will_Craig
    #1

    I'm relatively new to qt but when i set a style sheet on a label within my stacked widget i set the font colour to black using hex codes, this has worked before but now for some unknown reason when i run my app all fonts unspecified or specified are outputting white and i have no idea why, everything has been set to black as seen in attached images.0_1568007686297_Screen Shot 2019-09-09 at 3.41.08 pm.png
    0_1568007576322_Screen Shot 2019-09-09 at 3.18.09 pm.png

    J.HilkJ 1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      Do you modify the widget's palette by any chance? Using both QSS and QPalette does not work on a QLabel.

      (Z(:^

      W 1 Reply Last reply
      0
      • sierdzioS sierdzio

        Do you modify the widget's palette by any chance? Using both QSS and QPalette does not work on a QLabel.

        W Offline
        W Offline
        Will_Craig
        wrote on last edited by
        #3

        @sierdzio no i havent i didnt quite understand how palletes worked yet

        1 Reply Last reply
        0
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          OK.

          Ah, look at console output: it says that some properties are not recognized. Most likely you have changed the stylesheet and Qt can't parse it now. The really annoying thing about QSS is that when parsing fails, Qt will apply some of the styles, print a warning and ignore the rest of styling info. It's a perfect silent bug, very hard to notice and to fix.

          If you are using some source control like git, try bisecting back until you find a working version, then look into changes which happened since then. Also, if you have any compilation or runtime warnings - make sure you fix them.

          If you have upgraded Qt recently - try rolling back to the previous version. QSS sometimes breaks.

          (Z(:^

          1 Reply Last reply
          2
          • W Offline
            W Offline
            Will_Craig
            wrote on last edited by
            #5

            Thanks for the heads up on that runtime error i didnt even notice it, i fixed the bug causing that issue however it didnt have any effect of the text colour

            W 1 Reply Last reply
            0
            • W Will_Craig

              Thanks for the heads up on that runtime error i didnt even notice it, i fixed the bug causing that issue however it didnt have any effect of the text colour

              W Offline
              W Offline
              Will_Craig
              wrote on last edited by Will_Craig
              #6

              @sierdzio

              1 Reply Last reply
              0
              • sierdzioS Offline
                sierdzioS Offline
                sierdzio
                Moderators
                wrote on last edited by
                #7

                I have nothing to add, sorry, no further ideas. You need to try and find exactly which change caused the problem.

                (Z(:^

                1 Reply Last reply
                0
                • W Will_Craig

                  I'm relatively new to qt but when i set a style sheet on a label within my stacked widget i set the font colour to black using hex codes, this has worked before but now for some unknown reason when i run my app all fonts unspecified or specified are outputting white and i have no idea why, everything has been set to black as seen in attached images.0_1568007686297_Screen Shot 2019-09-09 at 3.41.08 pm.png
                  0_1568007576322_Screen Shot 2019-09-09 at 3.18.09 pm.png

                  J.HilkJ Offline
                  J.HilkJ Offline
                  J.Hilk
                  Moderators
                  wrote on last edited by
                  #8

                  @will_craig maybe it's a hierarchical issue, try to specify the exact object via #followed by the objectName

                  for example:

                  QLabel#label_8{
                  background:"#4CAF50";
                  font: 40pt "Helvetica" "#000000";
                  }
                  

                  Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                  Q: What's that?
                  A: It's blue light.
                  Q: What does it do?
                  A: It turns blue.

                  W 1 Reply Last reply
                  0
                  • J.HilkJ J.Hilk

                    @will_craig maybe it's a hierarchical issue, try to specify the exact object via #followed by the objectName

                    for example:

                    QLabel#label_8{
                    background:"#4CAF50";
                    font: 40pt "Helvetica" "#000000";
                    }
                    
                    W Offline
                    W Offline
                    Will_Craig
                    wrote on last edited by
                    #9

                    @j-hilk thanks illl give it a go may take a bit cause ill have to redo it for every object

                    1 Reply Last reply
                    0
                    • W Offline
                      W Offline
                      Will_Craig
                      wrote on last edited by Will_Craig
                      #10

                      @sierdzio i just added this highlighted line into the main.cpp file and the output changed all of the text colours that were not attached to one of the stacked widgets pages that had layouts applied. So the ones without layouts changed the pages with remained the same.0_1568086269202_Screen Shot 2019-09-09 at 10.05.16 pm.png

                      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