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. Lost My Qt Widgets StyleSheets
Qt 6.11 is out! See what's new in the release blog

Lost My Qt Widgets StyleSheets

Scheduled Pinned Locked Moved Solved General and Desktop
25 Posts 6 Posters 11.5k Views 2 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.
  • Christian EhrlicherC Christian Ehrlicher

    Please provide a minimal, compilable example of your problem.

    Ketan__Patel__0011K Offline
    Ketan__Patel__0011K Offline
    Ketan__Patel__0011
    wrote on last edited by
    #3

    @Christian-Ehrlicher

    My PushButton StyleSheets before the start My Application

    Capture_1.PNG

    My PushButton StyleSheets after the run My Application

    Capture_2.PNG

    you can see when i run my application that time pushbutton stylesheets are lost

    and this is not only in Pushbutton problem whatever controls i was used in my application every controls lost it's Stylesheet

    1 Reply Last reply
    0
    • Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #4

      Then you don't load them correct. But since you don't provide some source code to reproduce your problem we can't help.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      Ketan__Patel__0011K 1 Reply Last reply
      0
      • Christian EhrlicherC Christian Ehrlicher

        Then you don't load them correct. But since you don't provide some source code to reproduce your problem we can't help.

        Ketan__Patel__0011K Offline
        Ketan__Patel__0011K Offline
        Ketan__Patel__0011
        wrote on last edited by
        #5

        @Christian-Ehrlicher

        it is simple Stylesheet Like:

        QPushButton
        {
        background-color:rgb(241,92,34);
        }

        i am not used any other functionality to design any control, i just apply some Stylesheet on my qt application

        but whenever i run my application my application stylesheet are gone...

        1 Reply Last reply
        0
        • Christian EhrlicherC Online
          Christian EhrlicherC Online
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #6

          This is still no reproducible example. Create one which is compilable or we can't help - how should we know what else you're doing somewhere?

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          Ketan__Patel__0011K 1 Reply Last reply
          1
          • Christian EhrlicherC Christian Ehrlicher

            This is still no reproducible example. Create one which is compilable or we can't help - how should we know what else you're doing somewhere?

            Ketan__Patel__0011K Offline
            Ketan__Patel__0011K Offline
            Ketan__Patel__0011
            wrote on last edited by
            #7

            @Christian-Ehrlicher

            when i start My QFuture<void> thread And run Any function parallelly
            that time this problem is raised

            1 Reply Last reply
            0
            • Christian EhrlicherC Online
              Christian EhrlicherC Online
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on last edited by
              #8

              I'm giving up... provide code where we can reproduce the problem!

              and btw: you must not do any gui oeration outside the main thread.

              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
              Visit the Qt Academy at https://academy.qt.io/catalog

              Ketan__Patel__0011K 1 Reply Last reply
              2
              • Christian EhrlicherC Christian Ehrlicher

                I'm giving up... provide code where we can reproduce the problem!

                and btw: you must not do any gui oeration outside the main thread.

                Ketan__Patel__0011K Offline
                Ketan__Patel__0011K Offline
                Ketan__Patel__0011
                wrote on last edited by
                #9

                @Christian-Ehrlicher

                but way i can't use Any GUI controls in QFuture Thread ?

                jsulmJ 1 Reply Last reply
                0
                • Ketan__Patel__0011K Ketan__Patel__0011

                  @Christian-Ehrlicher

                  but way i can't use Any GUI controls in QFuture Thread ?

                  jsulmJ Offline
                  jsulmJ Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on last edited by
                  #10

                  @Ketan__Patel__0011 said in Lost My Qt Widgets StyleSheets:

                  but way i can't use Any GUI controls in QFuture Thread ?

                  Because it's not supported. UI may only be accessed from UI thread.
                  This is mentioned in the documentation: https://doc.qt.io/qt-5/thread-basics.html

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  Ketan__Patel__0011K 1 Reply Last reply
                  2
                  • jsulmJ jsulm

                    @Ketan__Patel__0011 said in Lost My Qt Widgets StyleSheets:

                    but way i can't use Any GUI controls in QFuture Thread ?

                    Because it's not supported. UI may only be accessed from UI thread.
                    This is mentioned in the documentation: https://doc.qt.io/qt-5/thread-basics.html

                    Ketan__Patel__0011K Offline
                    Ketan__Patel__0011K Offline
                    Ketan__Patel__0011
                    wrote on last edited by
                    #11

                    @jsulm

                    is it possible to run one or more function parallel in GUI thread ?

                    JonBJ jsulmJ 2 Replies Last reply
                    0
                    • Ketan__Patel__0011K Ketan__Patel__0011

                      @jsulm

                      is it possible to run one or more function parallel in GUI thread ?

                      JonBJ Offline
                      JonBJ Offline
                      JonB
                      wrote on last edited by JonB
                      #12

                      @Ketan__Patel__0011
                      No: how would it be possible to "run something in parallel" within the one GUI thread? Not to mention: why would you need to/bother anyway?

                      This is quite separate from running any non-GUI threads in parallel with the GUI thread.

                      1 Reply Last reply
                      0
                      • Ketan__Patel__0011K Ketan__Patel__0011

                        @jsulm

                        is it possible to run one or more function parallel in GUI thread ?

                        jsulmJ Offline
                        jsulmJ Offline
                        jsulm
                        Lifetime Qt Champion
                        wrote on last edited by
                        #13

                        @Ketan__Patel__0011 said in Lost My Qt Widgets StyleSheets:

                        is it possible to run one or more function parallel in GUI thread ?

                        Of course not. But why do you want to do this? Simply do your heavy stuff in parallel threads and emit signals there if UI needs to do something. And in the UI thread you connect to these signal and do what needs to be done. This is how this is done properly...

                        https://forum.qt.io/topic/113070/qt-code-of-conduct

                        Ketan__Patel__0011K 1 Reply Last reply
                        1
                        • jsulmJ jsulm

                          @Ketan__Patel__0011 said in Lost My Qt Widgets StyleSheets:

                          is it possible to run one or more function parallel in GUI thread ?

                          Of course not. But why do you want to do this? Simply do your heavy stuff in parallel threads and emit signals there if UI needs to do something. And in the UI thread you connect to these signal and do what needs to be done. This is how this is done properly...

                          Ketan__Patel__0011K Offline
                          Ketan__Patel__0011K Offline
                          Ketan__Patel__0011
                          wrote on last edited by
                          #14

                          @jsulm

                          Hiii

                          As you say i was change my code
                          i have stop updating my GUI controls in Thread.
                          And Updating my GUI Controls using emit signals

                          But still i am facing this problem..

                          jsulmJ 1 Reply Last reply
                          0
                          • Ketan__Patel__0011K Ketan__Patel__0011

                            @jsulm

                            Hiii

                            As you say i was change my code
                            i have stop updating my GUI controls in Thread.
                            And Updating my GUI Controls using emit signals

                            But still i am facing this problem..

                            jsulmJ Offline
                            jsulmJ Offline
                            jsulm
                            Lifetime Qt Champion
                            wrote on last edited by
                            #15

                            @Ketan__Patel__0011 Can you explain exact problem you have now? The thread is a bit old already.

                            https://forum.qt.io/topic/113070/qt-code-of-conduct

                            Ketan__Patel__0011K 1 Reply Last reply
                            0
                            • jsulmJ jsulm

                              @Ketan__Patel__0011 Can you explain exact problem you have now? The thread is a bit old already.

                              Ketan__Patel__0011K Offline
                              Ketan__Patel__0011K Offline
                              Ketan__Patel__0011
                              wrote on last edited by Ketan__Patel__0011
                              #16

                              @jsulm

                              my exact problem is some time i am lost my widgets stylesheets.
                              this problem is not continuously generating and i can't find exact sequence for it.

                              jsulmJ 1 Reply Last reply
                              0
                              • Ketan__Patel__0011K Ketan__Patel__0011

                                @jsulm

                                my exact problem is some time i am lost my widgets stylesheets.
                                this problem is not continuously generating and i can't find exact sequence for it.

                                jsulmJ Offline
                                jsulmJ Offline
                                jsulm
                                Lifetime Qt Champion
                                wrote on last edited by
                                #17

                                @Ketan__Patel__0011 Then you will need to show what you are doing with stylesheets

                                https://forum.qt.io/topic/113070/qt-code-of-conduct

                                Ketan__Patel__0011K 2 Replies Last reply
                                0
                                • jsulmJ jsulm

                                  @Ketan__Patel__0011 Then you will need to show what you are doing with stylesheets

                                  Ketan__Patel__0011K Offline
                                  Ketan__Patel__0011K Offline
                                  Ketan__Patel__0011
                                  wrote on last edited by
                                  #18

                                  @jsulm

                                  I am just changing my buttons or other controls stylesheet based of some condition..
                                  like

                                  if(IS_ Button_1_Clicked == true)
                                  {
                                         ui->pushbutton_1->setStyleSheet(MY_FIRST_STYLE);
                                  }
                                  else
                                  {
                                         ui->pushbutton_1->setStyleSheet(MY_SECOND_STYLE);
                                  }
                                  
                                  1 Reply Last reply
                                  0
                                  • jsulmJ jsulm

                                    @Ketan__Patel__0011 Then you will need to show what you are doing with stylesheets

                                    Ketan__Patel__0011K Offline
                                    Ketan__Patel__0011K Offline
                                    Ketan__Patel__0011
                                    wrote on last edited by
                                    #19

                                    @jsulm

                                    Here i am using

                                       QApplication::processEvents();
                                       QApplication::sendPostedEvents();
                                       this->update();
                                       this->show();
                                    

                                    is it right ?

                                    mrjjM 1 Reply Last reply
                                    0
                                    • Ketan__Patel__0011K Ketan__Patel__0011

                                      @jsulm

                                      Here i am using

                                         QApplication::processEvents();
                                         QApplication::sendPostedEvents();
                                         this->update();
                                         this->show();
                                      

                                      is it right ?

                                      mrjjM Offline
                                      mrjjM Offline
                                      mrjj
                                      Lifetime Qt Champion
                                      wrote on last edited by
                                      #20

                                      @Ketan__Patel__0011

                                      Hi
                                      Are you trying to update the stylesheets?

                                      Normally for dynamic properties in stylesheet one can do

                                      widget->style()->unpolish(widget);
                                      widget->style()->polish(widget);
                                      QEvent event(QEvent::StyleChange);
                                      QApplication::sendEvent(widget, &event);
                                      widget->update();
                                      widget->updateGeometry();
                                      

                                      Im not sure its what's wrong in your case.
                                      Is the stylesheet inline strings or do you load them from file?

                                      Ketan__Patel__0011K 1 Reply Last reply
                                      0
                                      • mrjjM mrjj

                                        @Ketan__Patel__0011

                                        Hi
                                        Are you trying to update the stylesheets?

                                        Normally for dynamic properties in stylesheet one can do

                                        widget->style()->unpolish(widget);
                                        widget->style()->polish(widget);
                                        QEvent event(QEvent::StyleChange);
                                        QApplication::sendEvent(widget, &event);
                                        widget->update();
                                        widget->updateGeometry();
                                        

                                        Im not sure its what's wrong in your case.
                                        Is the stylesheet inline strings or do you load them from file?

                                        Ketan__Patel__0011K Offline
                                        Ketan__Patel__0011K Offline
                                        Ketan__Patel__0011
                                        wrote on last edited by Ketan__Patel__0011
                                        #21

                                        @mrjj

                                        Thanks for reply

                                        i am trying to update widgets stylesheet.
                                        or i am not load stylesheet from file it just lnline string.

                                        1 Reply Last reply
                                        0
                                        • H Offline
                                          H Offline
                                          Hardy91
                                          wrote on last edited by
                                          #22

                                          A similar question posted here

                                          Ketan__Patel__0011K 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