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. best way to create diffrent theme in program

best way to create diffrent theme in program

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

    Hey guys, some question
    imagine we a gui that we created mostly in QtDesigner; the gui use lots of stylesheet for the element inside of it that mostly changed the look of elements (most of stylesheet add inside the designer itself)
    what is best way to create a dark and light mode for the gui? I mean how can we change the color of all element in gui in each mode that work best?
    I'm talking about just changing the color, not each time add the whole stylesheet to it with different color?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      If you want to change an element of a stylesheet you have to re-apply the stylesheet afterward.

      So if you have "changeable" style sheets, the most simple is to keep them in strings with arguments so that you can regenerate them at will.

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

      S 1 Reply Last reply
      2
      • SGaistS SGaist

        Hi,

        If you want to change an element of a stylesheet you have to re-apply the stylesheet afterward.

        So if you have "changeable" style sheets, the most simple is to keep them in strings with arguments so that you can regenerate them at will.

        S Offline
        S Offline
        saeid0034
        wrote on last edited by
        #3

        @SGaist so I cant just apply it in designer and just later change the color of it?
        other then that what is the best way to apply the stylesheet to whole widgets? should I just create a long stylesheet and apply all styles to all element inside it and put it to a top widget?

        SGaistS 1 Reply Last reply
        0
        • S saeid0034

          @SGaist so I cant just apply it in designer and just later change the color of it?
          other then that what is the best way to apply the stylesheet to whole widgets? should I just create a long stylesheet and apply all styles to all element inside it and put it to a top widget?

          SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @saeid0034 said in best way to create diffrent theme in program:

          @SGaist so I cant just apply it in designer and just later change the color of it?

          You would need to retrieve that stylesheet, parse it,
          do the modification and then re-apply it.

          other then that what is the best way to apply the stylesheet to whole widgets? should I just create a long stylesheet and apply all styles to all element inside it and put it to a top widget?

          That depends on what you want to change and the structure of your widgets.

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

          S 1 Reply Last reply
          1
          • SGaistS SGaist

            @saeid0034 said in best way to create diffrent theme in program:

            @SGaist so I cant just apply it in designer and just later change the color of it?

            You would need to retrieve that stylesheet, parse it,
            do the modification and then re-apply it.

            other then that what is the best way to apply the stylesheet to whole widgets? should I just create a long stylesheet and apply all styles to all element inside it and put it to a top widget?

            That depends on what you want to change and the structure of your widgets.

            S Offline
            S Offline
            saeid0034
            wrote on last edited by
            #5

            @SGaist can I do somthing like put formating argument in Stylesheet in QDesigner then latter change it using the format?

            JonBJ 1 Reply Last reply
            0
            • S saeid0034

              @SGaist can I do somthing like put formating argument in Stylesheet in QDesigner then latter change it using the format?

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

              @saeid0034
              Indeed, but this is down to you 100% to write the code to read & replace, there is nothing in QSS/CSS that will do that.

              S 1 Reply Last reply
              1
              • JonBJ JonB

                @saeid0034
                Indeed, but this is down to you 100% to write the code to read & replace, there is nothing in QSS/CSS that will do that.

                S Offline
                S Offline
                saeid0034
                wrote on last edited by saeid0034
                #7

                @JonB I'm using two color palette for each dark and light theme, so you saying for example its better to get the stylesheet of the parent widget and just replace the values of it to other theme and reApply it? is it the most efficient way?

                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