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. QMacStyle::standardIcon returns icons that don't match the mac theme.

QMacStyle::standardIcon returns icons that don't match the mac theme.

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

    Using Qt 5.9.6 on Mac High Sierra, I'm tasked with creating a window with a custom titlebar, while maintaining some of the native look and feel across platforms.

    I was hoping to grab the window control icons using QStyle::standardIcon, which I believe should be calling the implementation of QMacStyle::standardIcon

    I'm passing QStyle::SP_TitleBarCloseButton, QStyle::SP_TitleBarMaxButton and QStyle::SP_TitleBarMinButton.

    The icons that are returned don't match the native icons at all. Would an upgrade to Qt 5.12 help, or will I need to create my own images to try emulate the native look?

    Alternative approaches also welcome!

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

      Hi and welcome to devnet,

      Upgrading is a good idea since 5.12 is the current LTS.

      That said, what are you getting ?

      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
      • M Offline
        M Offline
        micheal
        wrote on last edited by
        #3

        Upgrading has been on the back burner for a while, I'm in favour of it and could certainly make a good argument for doing it sooner if it would fix this problem!

        These are the icons that are being returned:0_1547689642133_Screen Shot 2019-01-17 at 12.47.01 pm.png
        These are the icons I was hoping for:0_1547689677155_Screen Shot 2019-01-17 at 12.46.33 pm.png

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

          Can you provide a minimal sample code that reproduces that ?

          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
          • M Offline
            M Offline
            micheal
            wrote on last edited by
            #5

            Here's a short sample, which results in the following window:

            0_1547766781049_Screen Shot 2019-01-18 at 10.12.45 am.png

            int main(int argc, char* argv[])
            {
            	QApplication app(argc, argv);
            	QMainWindow window;
            
            	QStyle *style = app.style();
            	QIcon closeIcon = style->standardIcon(QStyle::SP_TitleBarCloseButton);
            
            	QPushButton button;
            	button.setIcon(closeIcon);
            
            	window.setCentralWidget(&button);
            	window.show();
            
            	return app.exec();
            }
            
            1 Reply Last reply
            0
            • M Offline
              M Offline
              micheal
              wrote on last edited by
              #6

              I tested this out on 5.12, making sure to first specify

              setStyle(QStyleFactory::create("macintosh"))
              

              but got the same result.

              Solution is to make images that look native and use those instead, not much of a solution but it seems to be the only option.

              K 1 Reply Last reply
              0
              • M micheal

                I tested this out on 5.12, making sure to first specify

                setStyle(QStyleFactory::create("macintosh"))
                

                but got the same result.

                Solution is to make images that look native and use those instead, not much of a solution but it seems to be the only option.

                K Offline
                K Offline
                kenchan
                wrote on last edited by
                #7

                @micheal
                I build my app on both mac and windows and use

                app->setStyle("fusion");
                

                I get the native Mac look and feel on the Mac and the windows look and feel on windows with just that piece of code.

                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