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. After using my Qt desktop application for a while and also using other applications simultaneously the stylesheet of my Qt desktop application changes.

After using my Qt desktop application for a while and also using other applications simultaneously the stylesheet of my Qt desktop application changes.

Scheduled Pinned Locked Moved Unsolved General and Desktop
stylesheetdesktop
15 Posts 4 Posters 1.2k 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.
  • J JonB
    22 Nov 2021, 10:43

    @andyP said in After using my Qt desktop application for a while and also using other applications simultaneously the stylesheet of my Qt desktop application changes.:

    But after a while using my application and other programs simultaneously the stylesheets changes.

    I don't think anyone can diagnose this.

    However when the stylesheet changes the button is instead shown as light blue when starting:

    If you replace the first stylesheet rule by the second one you will lose the first stylesheet's green foreground/background, if that is what you mean. Then the light blue presumably comes from some other applicable rule you have.

    H Offline
    H Offline
    Hardy91
    wrote on 10 Jul 2024, 11:46 last edited by
    #3

    @JonB said in After using my Qt desktop application for a while and also using other applications simultaneously the stylesheet of my Qt desktop application changes.:

    But after a while using my application and other programs simultaneously the stylesheets changes.

    same issue I am facing with Qt 5.15.1. Randomly it fall back to the default style and all the stylsheet applied on different widgets get lost. and it is random and only reproduce 3 out 10 try

    J 1 Reply Last reply 10 Jul 2024, 11:48
    0
    • H Hardy91
      10 Jul 2024, 11:46

      @JonB said in After using my Qt desktop application for a while and also using other applications simultaneously the stylesheet of my Qt desktop application changes.:

      But after a while using my application and other programs simultaneously the stylesheets changes.

      same issue I am facing with Qt 5.15.1. Randomly it fall back to the default style and all the stylsheet applied on different widgets get lost. and it is random and only reproduce 3 out 10 try

      J Offline
      J Offline
      JonB
      wrote on 10 Jul 2024, 11:48 last edited by
      #4

      @Hardy91 I don't think anyone can help you with that unless you find some reproducer.

      1 Reply Last reply
      0
      • H Offline
        H Offline
        Hardy91
        wrote on 10 Jul 2024, 16:26 last edited by
        #5

        @JonB I do agree with your point, but the problem is its a big code and I can't share it here. and I try making a small sample application on which it is not reproducing. I even can't post the screenshot of the problem here. but what the OP reported I am facing the exact same issue.
        The real problem here is it is not 100% reproducible and there is no particular step.

        S 1 Reply Last reply 10 Jul 2024, 18:27
        0
        • H Hardy91
          10 Jul 2024, 16:26

          @JonB I do agree with your point, but the problem is its a big code and I can't share it here. and I try making a small sample application on which it is not reproducing. I even can't post the screenshot of the problem here. but what the OP reported I am facing the exact same issue.
          The real problem here is it is not 100% reproducible and there is no particular step.

          S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 10 Jul 2024, 18:27 last edited by
          #6

          @Hardy91 hi,

          Are you setting your stylesheet only once ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • H Offline
            H Offline
            Hardy91
            wrote on 12 Jul 2024, 09:18 last edited by
            #7

            @SGaist So here is what happing in my class

            1. Inherited the QApplication class and in the constructor of the inherited class setStylesheet() by reading the QSS Stylesheet file.

            getStyleSheetFile( QString fileName )
            {
            QFile file( fileName );
            file.open( QFile::ReadOnly | QFile::Text );
            QString styleSheet = QLatin1String( file.readAll() );
            return styleSheet;
            }

            1. After this, we created so many other widgets and dialog and in some dialogs we set the styesheet where we want different stylesheet.
            2. Now when we run the application most of the time it is working fine and showing the stylesheets as set.
            3. but randomly sometimes it switch back to the qt default style and all the stylesheet is gone on almost all the widget.

            Some key points here.

            1. After stylesheet is gone I opened a dilaog in which I set the stylesheet on QFrame/combobox/radiobutton/pushbutton. (which usually worked as setstylesheet ) is also not applying the stylesheet and showing the default Qt style and some places black or grey backgound. On some push button I even set the border to 0 px is also now showing the border as default style.
            2. I tried to reproduce this issue for about 8 hr and only able to reproduce 2 times. that too randomly.

            Most Important one: our application support the batch execution of some backend operation which updates the UI and those backend operation is executed in a boost thread and through our custom observer design pattern/callbacks it update the UI elements like log widow some labels stylesheet. and mostly this issue reproduce when we perform this operation but its random. During normal operation of application it is working fine.

            S 1 Reply Last reply 12 Jul 2024, 09:23
            0
            • H Hardy91
              12 Jul 2024, 09:18

              @SGaist So here is what happing in my class

              1. Inherited the QApplication class and in the constructor of the inherited class setStylesheet() by reading the QSS Stylesheet file.

              getStyleSheetFile( QString fileName )
              {
              QFile file( fileName );
              file.open( QFile::ReadOnly | QFile::Text );
              QString styleSheet = QLatin1String( file.readAll() );
              return styleSheet;
              }

              1. After this, we created so many other widgets and dialog and in some dialogs we set the styesheet where we want different stylesheet.
              2. Now when we run the application most of the time it is working fine and showing the stylesheets as set.
              3. but randomly sometimes it switch back to the qt default style and all the stylesheet is gone on almost all the widget.

              Some key points here.

              1. After stylesheet is gone I opened a dilaog in which I set the stylesheet on QFrame/combobox/radiobutton/pushbutton. (which usually worked as setstylesheet ) is also not applying the stylesheet and showing the default Qt style and some places black or grey backgound. On some push button I even set the border to 0 px is also now showing the border as default style.
              2. I tried to reproduce this issue for about 8 hr and only able to reproduce 2 times. that too randomly.

              Most Important one: our application support the batch execution of some backend operation which updates the UI and those backend operation is executed in a boost thread and through our custom observer design pattern/callbacks it update the UI elements like log widow some labels stylesheet. and mostly this issue reproduce when we perform this operation but its random. During normal operation of application it is working fine.

              S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 12 Jul 2024, 09:23 last edited by
              #8

              @Hardy91 Just to be sure, you are not updating Qt's GUI elements directly from these boost threads ?

              Does your "custom observer design pattern/callbacks" take that element into account ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              H 1 Reply Last reply 12 Jul 2024, 09:31
              0
              • S SGaist
                12 Jul 2024, 09:23

                @Hardy91 Just to be sure, you are not updating Qt's GUI elements directly from these boost threads ?

                Does your "custom observer design pattern/callbacks" take that element into account ?

                H Offline
                H Offline
                Hardy91
                wrote on 12 Jul 2024, 09:31 last edited by Hardy91 7 Dec 2024, 09:34
                #9

                @SGaist .
                my question is, even if this is happening then why this problem is not always, why this is random behavior. I know here we are talking about the threading which no one can predict. but still technically it should reproduce more often not 2 times in 8 hr.

                Does your "custom observer design pattern/callbacks" take that element into account ?
                To be honest, I am not sure that it is not happening. But I think it's not otherwise this would be easily reproducible. we are just calling callbacks and there we are emitting the signals to the UI classes and updating the result on UI.

                Hypothetically even if due to this stylesheet is gone but it should recover when we open a new instance of the QDialog where we set the stylesheet agian.

                Have you ever seen the same behavior?

                1 Reply Last reply
                0
                • H Offline
                  H Offline
                  Hardy91
                  wrote on 12 Jul 2024, 09:41 last edited by
                  #10

                  A similar question posted here

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on 12 Jul 2024, 10:03 last edited by
                    #11

                    There's the catch: calling functions on GUI elements from a different thread is currently in the "undefined behaviour" territory so you might just be lucky that it's not crashing your application at all.

                    What I would start with is to ensure that there's no direct call anywhere. Next step is to check what is connected and how the signals are emitted.

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    2
                    • H Offline
                      H Offline
                      Hardy91
                      wrote on 25 Jul 2024, 09:11 last edited by Hardy91
                      #12

                      Hi @SGaist, thanks for your valuable feedback.
                      I resolved this issue.
                      Root-cause: Directly updating the UI components from the non-UI thread(aka main thread). As, the code size is really big it was really challenge to find out where it was happening.

                      Does your "custom observer design pattern/callbacks" take that element into account ?
                      Yes, the framework support this thing, but somewhere it was broken.

                      1 Reply Last reply
                      0
                      • S Offline
                        S Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on 25 Jul 2024, 18:57 last edited by SGaist
                        #13

                        Glad you found out and fixed it !

                        Since you have it working now, please mark the thread as solved using so other forum users may know a solution has been found :-)

                        Interested in AI ? www.idiap.ch
                        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                        1 Reply Last reply
                        0
                        • H Offline
                          H Offline
                          Hardy91
                          wrote on 29 Jul 2024, 06:00 last edited by
                          #14

                          HI @SGaist I am not the OP for this form/question.

                          1 Reply Last reply
                          0
                          • S Offline
                            S Offline
                            SGaist
                            Lifetime Qt Champion
                            wrote on 29 Jul 2024, 19:59 last edited by
                            #15

                            Right ! Your part was way longer than the original conversation 😅

                            Interested in AI ? www.idiap.ch
                            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                            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