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. [SOLVED] How to get the current application style name
QtWS25 Last Chance

[SOLVED] How to get the current application style name

Scheduled Pinned Locked Moved General and Desktop
10 Posts 4 Posters 8.9k 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.
  • D Offline
    D Offline
    dvillalobos
    wrote on 27 Nov 2013, 16:46 last edited by
    #1

    Hi all,

    ¿How can I get the current application style name? I want to get one of texts returned by QStyleFactory::keys().

    Regards

    Regards

    David

    1 Reply Last reply
    0
    • P Offline
      P Offline
      poorBob
      wrote on 27 Nov 2013, 20:03 last edited by
      #2

      What about this:
      @qDebug() << QApplication::style()->objectName()@
      You can also check this: "QApplication::StyleSheet()":http://qt-project.org/doc/qt-4.8/qapplication.html#styleSheet-prop

      I'm not sure if this is what You are looking for,,,

      with best regards,
      Robert

      1 Reply Last reply
      0
      • D Offline
        D Offline
        dvillalobos
        wrote on 27 Nov 2013, 20:09 last edited by
        #3

        Hi poorBob, thanks for your reply.

        It just print: ""

        Regards

        Regards

        David

        1 Reply Last reply
        0
        • M Offline
          M Offline
          MuldeR
          wrote on 28 Nov 2013, 13:32 last edited by
          #4

          Maybe try:
          @qDebug("%s", typeid(QApplication::style()).name();@

          Note: You may need a special compiler option, like "/GR" for MSVC, for this to work as expected. I'm not so sure about GCC.

          My OpenSource software at: http://muldersoft.com/

          Qt v4.8.6 MSVC 2013, static/shared: http://goo.gl/BXqhrS

          Go visit the coop: http://youtu.be/Jay...

          1 Reply Last reply
          0
          • D Offline
            D Offline
            dvillalobos
            wrote on 28 Nov 2013, 13:37 last edited by
            #5

            Hi MuldeR, thanks for the replay.

            It prints: P6QStyle, and I need one of the following:

            ("Oxygen", "Windows", "Motif", "CDE", "Plastique", "GTK+", "Cleanlooks")

            Regards

            Regards

            David

            1 Reply Last reply
            0
            • R Offline
              R Offline
              raven-worx
              Moderators
              wrote on 28 Nov 2013, 13:43 last edited by
              #6

              on what operating system did you check it? I guess a linux variant...
              This is what i get returned (Windows 7):
              @
              QApplication::style()->objectname(); //"windowsvista"
              QApplication::style()->metaObject()->className(); //"QWindowsVistaStyle"
              @
              where
              @
              QStyleFactory::keys();
              //("Windows", "WindowsXP", "WindowsVista", "Motif", "CDE", "Plastique", "Cleanlooks")
              @

              --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
              If you have a question please use the forum so others can benefit from the solution in the future

              1 Reply Last reply
              2
              • D Offline
                D Offline
                dvillalobos
                wrote on 28 Nov 2013, 13:49 last edited by
                #7

                Hi raven-worx, thanks for your replay.

                I use Linux 64 Bits, Qt 4.8.

                @QApplication::style()->objectname();@
                Prints: error: 'class QStyle' has no member named 'objectname'

                @QApplication::style()->metaObject()->className();@
                Prints: QStyleSheetStyle

                And I need the name of the current Style:
                (“Oxygen”, “Windows”, “Motif”, “CDE”, “Plastique”, “GTK+”, “Cleanlooks”)

                Regards

                David

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  MuldeR
                  wrote on 28 Nov 2013, 13:50 last edited by
                  #8

                  [quote author="David Villalobos" date="1385645825"]Hi MuldeR, thanks for the replay.

                  It prints: P6QStyle, and I need one of the following:

                  ("Oxygen", "Windows", "Motif", "CDE", "Plastique", "GTK+", "Cleanlooks")

                  Regards[/quote]

                  Sorry, I meant:
                  @qDebug("%s", typeid(*QApplication::style()).name();@

                  This gives me the following result:
                  @class QPlastiqueStyle@

                  My OpenSource software at: http://muldersoft.com/

                  Qt v4.8.6 MSVC 2013, static/shared: http://goo.gl/BXqhrS

                  Go visit the coop: http://youtu.be/Jay...

                  1 Reply Last reply
                  0
                  • R Offline
                    R Offline
                    raven-worx
                    Moderators
                    wrote on 28 Nov 2013, 13:55 last edited by
                    #9

                    [quote author="David Villalobos" date="1385646560"]
                    @QApplication::style()->objectname();@
                    Prints: error: 'class QStyle' has no member named 'objectname'
                    [/quote]
                    it's a typo mistake... should be objectName().
                    So you have a stylesheet style set in your application. This is your style then. What exactly do you want to do with the stylename? Why do you need it to be contained in the QStyleFactory::keys() list?

                    --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                    If you have a question please use the forum so others can benefit from the solution in the future

                    1 Reply Last reply
                    0
                    • D Offline
                      D Offline
                      dvillalobos
                      wrote on 28 Nov 2013, 14:03 last edited by
                      #10

                      Hi.

                      All your aswers help me to finf the problem.

                      In the startup class I have this line:
                      @qApp->setStyleSheet(QString::fromUtf8(styleFile.readAll()));@
                      This line is the problem.

                      If commented:
                      @qDebug() << QApplication::style()->metaObject()->className();@
                      Prints: QPlastiqueStyle

                      Regards.

                      Regards

                      David

                      1 Reply Last reply
                      0

                      1/10

                      27 Nov 2013, 16:46

                      • Login

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