Results 1 to 4 of 4

Thread: Qt Application Not Using GTK Theme on Linux

  1. #1
    Join Date
    Nov 2016
    Posts
    2
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Qt Application Not Using GTK Theme on Linux

    When I run my Qt application on Linux Mint Cinnamon 18 it doesn't use the GTK theme colours or system font. Qt Creator has the same issue, but other Qt applications I've tried (XnView MP and qBittorrent) do correctly use my GTK theme. It therefore appears there is a way to get it to work, but I'm unsure how.

    I tried this (even though it should be true by default):

    Qt Code:
    1. QApplication::setDesktopSettingsAware(true);
    To copy to clipboard, switch view to plain text mode 
    That didn't work, so I tried forcing the style to Fusion with:

    Qt Code:
    1. QApplication::setStyle(QStyleFactory::create("Fusion"));
    To copy to clipboard, switch view to plain text mode 
    This too had no effect. I asked on Stack Overflow and somebody said he solved the issue using:

    Qt Code:
    1. qApp->setStyle(new QProxyStyle());
    To copy to clipboard, switch view to plain text mode 
    Unfortunately that didn't work for me. I've looked at the qBittorrent code to try and work how why that follows the GTK theme while my application doesn't, but I couldn't see anything relevant to the issue. I also tried making a very simple Qt application, but that too doesn't use the theme. I'm therefore at a loss as to why other Qt application follow the GTK theme, but Qt Creator and any application I make doesn't

    Can anyone suggest what I should do to make the application use the GTK theme?

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Qt Application Not Using GTK Theme on Linux

    If it works for other Qt applications but not your own, have the been built against the same Qt?

    Otherwise the Qt version your app is using might lack the GTK platform theme plugin.

    Cheers,
    _

  3. #3
    Join Date
    Nov 2016
    Posts
    2
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Qt Application Not Using GTK Theme on Linux

    I'm using Qt 5.7 and the issue of programs not using the GTK theme isn't just with my application, but also with Qt Creator. It could be, as you suggest, that XnView MP and qBittorrent work because they were built with an earlier version of Qt (XnView MP uses 5.4).

    If I run the below line on Linux the only styles it displays are Fusion and Windows, so, as you say, it looks like I don't have the GTK style.

    Qt Code:
    1. QMessageBox::information(this, "Styles", QStyleFactory::keys().join(" "), QMessageBox::Ok);
    To copy to clipboard, switch view to plain text mode 
    However, according to this Qt blog post, the other styles have been deprecated and are no longer being developed, so using them probably isn't a good idea. Furthermore, the linked page for downloading older styles shows an empty directory, so it looks like the older styles aren't even available for download any more.

    As things stand the linux version of the application look terrible, so I'd like to get them working with the GTK theme, but I still don't have a clue how to achieve this.

    Any suggestions?

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Qt Application Not Using GTK Theme on Linux

    Quote Originally Posted by Assoluto View Post
    I'm using Qt 5.7 and the issue of programs not using the GTK theme isn't just with my application, but also with Qt Creator. It could be, as you suggest, that XnView MP and qBittorrent work because they were built with an earlier version of Qt (XnView MP uses 5.4).
    The version doesn't matter as much as how the version was built and which of its plugins are available.

    Quote Originally Posted by Assoluto View Post
    If I run the below line on Linux the only styles it displays are Fusion and Windows, so, as you say, it looks like I don't have the GTK style.
    I am not sure if there is an explicit, stand-alone GTK+ style, my guess is that this is provided by the GTK+ platform integration plugin or a platform theme plugin.

    Quote Originally Posted by Assoluto View Post
    However, according to this Qt blog post, the other styles have been deprecated and are no longer being developed, so using them probably isn't a good idea.
    Those are just the explicit styles shipped with Qt, the core idea is to adapt to the platform through platform plugins.

    If you have installed these other two Qt applications through the distribution's installation mechanism, then they are built against the distributionn shipped Qt, which almost certainly comes with the integration plugins for GTK+ based environments.

    You Qt version might not, or something might block the respective plugin from being loaded.

    Cheers,
    _

Similar Threads

  1. Replies: 2
    Last Post: 13th April 2022, 19:26
  2. Replies: 1
    Last Post: 3rd January 2016, 23:35
  3. Linux - Support system's theme change
    By agarny in forum Qt Programming
    Replies: 2
    Last Post: 10th July 2011, 17:12
  4. Icon from theme
    By wirasto in forum Qt Programming
    Replies: 1
    Last Post: 22nd December 2009, 13:42
  5. Change Qt theme while running
    By Macok in forum Qt Programming
    Replies: 7
    Last Post: 12th February 2009, 20:57

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.