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. How to set different theme in the application created in QT.
Forum Updated to NodeBB v4.3 + New Features

How to set different theme in the application created in QT.

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 3.8k 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.
  • V Offline
    V Offline
    viraj1909
    wrote on last edited by
    #1

    I have created a application using QT and C++, in that particular application I want to have theme support, i.e. to have multiple theme in the application and it can be chosen by the user as per his/her connivance.
    Is there an other approach then setting different CSS for each window.
    using { Qt Creator 4.12.2
    Based on Qt 5.14.2 (GCC 5.3.1 20160406 (Red Hat 5.3.1-6), 64 bit)
    Built on Jun 2 2020 04:15:50 }

    Pl45m4P 1 Reply Last reply
    0
    • V viraj1909

      I have created a application using QT and C++, in that particular application I want to have theme support, i.e. to have multiple theme in the application and it can be chosen by the user as per his/her connivance.
      Is there an other approach then setting different CSS for each window.
      using { Qt Creator 4.12.2
      Based on Qt 5.14.2 (GCC 5.3.1 20160406 (Red Hat 5.3.1-6), 64 bit)
      Built on Jun 2 2020 04:15:50 }

      Pl45m4P Online
      Pl45m4P Online
      Pl45m4
      wrote on last edited by Pl45m4
      #2

      @viraj1909

      QPalette, other than that there is only stylesheet.

      • https://doc.qt.io/qt-6/qpalette.html#details

      Btw you can set one global stylesheet for your whole application, not only one for each widget/window.

      qApp->setStylesheet(....);
      

      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

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

        Hi and welcome to devnet,

        You can create custom QStyle. See this example.

        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
        • V Offline
          V Offline
          viraj1909
          wrote on last edited by
          #4

          @SGaist Thank you, have seen this but the issue is, some of my labels are used to show images and some of my labels are used to show the text, in which i want to have the theme set to only the label which has text not the image one, same way i have use many widgets in different way to overcome my application.

          SGaistS 1 Reply Last reply
          0
          • V viraj1909

            @SGaist Thank you, have seen this but the issue is, some of my labels are used to show images and some of my labels are used to show the text, in which i want to have the theme set to only the label which has text not the image one, same way i have use many widgets in different way to overcome my application.

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

            @viraj1909 since it's your style you can apply the changes you want based on the rules you set. Hence, check if the label has text and only then apply your changes.

            You can also create dedicate styles that you apply only to certain widgets.

            In your case, maybe a QProxyStyle would be enough.

            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
            1

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved