How does one make GTK3 look native on Windows 7? - css

I am trying to make my GTK3 application look native on Windows 7. I tried the answer in the following question How to get native windows decorations on GTK3 on Windows 7+ and MSYS2
But it doesn't work. My GTK3 version on windows is 3.22 and I am using the Vala language. Tried with GTK3 version 3.20 to no avail either. I also tried changing the background color of the application in the code itself with the CssProvider and it works in Ubuntu, but not in Windows. In Windows, the application theme and all CSS manual settings are ignored.
Is there any way to achieve this? Thanks.

It worked by calling in the code, before displaying the main application window with show_all () :
Gtk.Settings.get_default ().gtk_theme_name = "win32";
When using a custom theme, the location of the theme should be: "YourApplicationExecutable\share\themes\ThemeFolder" as per described in the accepted answer of How to get native windows decorations on GTK3 on Windows 7+ and MSYS2
and the name set with gtk_theme_name in the code should be the name of the folder containing the theme.
Note that the method get_default () gets you the default GDK screen. If you want more control over specific widgets, use instead the method get_settings () over the specific widget that you want to change the theme for.
Sources:
How to get native windows decorations on GTK3 on Windows 7+ and MSYS2
https://valadoc.org/gtk+-3.0/Gtk.CssProvider.html
https://valadoc.org/gtk+-3.0/Gtk.Settings.html

Related

Why do gnome apps ignore parts of gtk 3 themes?

I am extremely new to making gtk 3 themes, and I have created a theme that is working with any app that is using titlebars, but any gnome app (such as shotwell, or rhythmbox) is ignoring the theme completely. I have determined it is due to the gnome apps using header-bars rather than title bars, but the header-bars will not using background-color or any other css attribute other than background-image. Any help is appreciated
Because gnome apps partly use default system user interface, which maybe different from gtk3, you need to change settings both in apps (if any) and in the system - gnome settings. It depends from app to app.

can my Qt Application get Mac look on windows

As Qt application will be in native look and feel.
I want to get mac look and feel for my Qt application. Is it possible to do so?
It is possible to change look and feel of Qt application by using styles:
QApplication::setStyle("macintosh");
List of available styles is given by:
QStringList list = QStyleFactory::keys();
But for example on Windows Mac style is typically unavailable. I tested on Windows machine with Qt 5.4 - only Windows (Windows, WindowsXP and WindowsVista) and Fusion styles are available - you can switch between them.
Of course, Windows style is default for Windows. It is advised to set style before constructing QApplication.

How can I compile Qt app in Linux using Windows style?

I'm developing a Qt Widgets application and due to compile performance issues, I started developing it in Linux Ubuntu instead of Windows. The problems is that, when compiled and run, the app appears with traditional Ubuntu style instead of Windows (7) style. Since the app is only for Windows, I'ld like to know how can I compile it inside Linux Ubuntu but making it appear with Windows style.
I tried using QApplication::setStyle(QStyleFactory::create("QWindowsStyle")); in main.cpp, without success. I guess the QtAssistant docs just aren't clear enough on how can I do this change. Any help will be appreciated.
Could you by any chance be using a Qt package that is compiled without the style? Can you try running QStyleFactory::keys() to verify that the style exists?
It can't be done, since the style's elements are rendered by Windows (or OS X), not by Qt. Qt's style implementation asks the OS libraries to provide bitmaps of those elements. If you wanted to, you could modify the style to use a disk cache for static items. You could then use the style on all platforms. The problem is that these OS-provided bitmaps are a part of the OS and thus non-redistributable.
The only plastform-specific style that at least used to be available everywhere was the old Windows 95 style, in times of Qt 3. I'm not sure what its current status is.
First check out put of QStyleFactory::keys()
then set the look by calling
qApp->setStyle("Windows");
This command will give you windows 98 look. If you want windows vista look you should configure qt sources with -style-windowsvista and rebuild all sources.
UPDATE
according to http://doc.qt.io/qt-5/qstylefactory.html#details qt style is not platform independent. So IT IS IMPOSSIBLE to have that native look in not windows platform. It's worth mentioning that in windows also Windows SDK itself is required in order to build sources of Qt otherwise your application will look like windows 98 in windows 7.

Is it possible to set icon for a custom file used by my app

I would like to create and app using Qt which will use custom files. The app will be available on Windows, OS X and Linux.
The idea is to have a custom icon for my file type (e.g. when you install Adobe's Master Collection, .as, .fla, .ps, etc. files have they own icons).
As far as I know Qt only helps you with app icon. I did not find any kind of support for this kind of problem.
This seems to be an OS problem. Do I need to create scripts to run on app install? (I will be using Bitrock's install builder to provide installers)
How can I achive this behaviour on all OSs?

Test WinXP look on other platforms?

Is there a way to test the look of my UI on Windows or other platforms from my Linux machine? I'd like to have some idea of how it will look without having to rebuilding the project on a windows machine.
At the command line for your program you can specify the style:
http://qt-project.org/doc/qt-5.0/qtwidgets/qapplication.html#QApplication
-style= style, sets the application GUI style. Possible values depend on your system configuration. If you compiled Qt with additional styles or have additional styles as plugins these will be available to the -style command line option. You can also set the style for all Qt applications by setting the QT_STYLE_OVERRIDE environment variable.
In some older documentation it mentions:
Possible values are motif, windows, and platinum.
I just tried this on Windows 8 with Qt 4.8.4, and I got no change adding in "style=platinum" or any of the others, and apparently the build of Qt that I got did not come with the additional style plugins. So, build Qt with the additional styles, and then you can preview the look for other OS's.
Hope that helps.

Resources