Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Forum Updated on Feb 6th

    Unsolved Problem with style sheet fonts

    General and Desktop
    3
    10
    454
    Loading More Posts
    • 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
      Will_Craig last edited by 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.Hilk 1 Reply Last reply Reply Quote 0
      • sierdzio
        sierdzio Moderators last edited by

        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 Reply Quote 0
        • W
          Will_Craig @sierdzio last edited by

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

          1 Reply Last reply Reply Quote 0
          • sierdzio
            sierdzio Moderators last edited by

            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 Reply Quote 2
            • W
              Will_Craig last edited by

              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 Reply Quote 0
              • W
                Will_Craig @Will_Craig last edited by Will_Craig

                @sierdzio

                1 Reply Last reply Reply Quote 0
                • sierdzio
                  sierdzio Moderators last edited by

                  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 Reply Quote 0
                  • J.Hilk
                    J.Hilk Moderators @Will_Craig last edited by

                    @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

                    Qt Needs YOUR vote: https://bugreports.qt.io/browse/QTQAINFRA-4121


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

                    W 1 Reply Last reply Reply Quote 0
                    • W
                      Will_Craig @J.Hilk last edited by

                      @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 Reply Quote 0
                      • W
                        Will_Craig last edited by Will_Craig

                        @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 Reply Quote 0
                        • First post
                          Last post