Why don't my Qt apps look like the ones built by others?

I just built a simple Qt app with Qt Creator. It looks like this.

http://i.imgur.com/mScXa.png

It doesn’t look anything like the KDE apps on my hard drive. See the difference for yourself:

http://i.imgur.com/VdsEh.png

Why does my Qt app look like it was built in the Windows 98 era? Do the KDE apps use a skin or something?

I should note that I’m running KDE 4.5 with Qt 4.6 and that I compiled my app with Qt 4.7.0.

Hi,

there are several ways how it is possible to influence the look of Qt applications. As far a I remember the regular behavior is that it match to the current desktop settings. This means that running Qt applications under KDE makes them look like all other KDE applications, under windows it looks like a regular windows app, etc… This normal behavior can be overwritten by the developer of the applications with different style settings. How this is possible is documented in the documentation of Qt.

The reason why your application looks like this could have therefore many reasons. One ist Qt applications don’t equal KDE applications completely. As described above they should have almost the same style but the KDE styles are configured with KDE system settings. For Qt apps this settings can be overwritten by the qt-styles configured with qtconfig. Last but not least the application can override all of the configured styles.

Hope this makes it a bit clearer where to search for the different look.

Qt Creator itself seems to apply a Windows skin when I use Windows 7, the current GTK theme when I use Ubuntu (GNOME) and the current KDE style when I use openSUSE (KDE). Can I configure my project with Qt Creator in such a way that these settings are used instead of what I presume is the generic Qt look?

You can influence some aspects (colours, fonts) of QT applications with /usr/bin/qtconfig (for QT4 apps) and /usr/lib/qt3/bin/qtconfig (for QT3 apps). For QT4, the configuration is saved in the file ~/.config/Trolltech.conf. Once generated, you can edit this file. When you’re happy with the settings there, you might want to copy it in /etc/skel/.config/Trolltech.conf with appropriate mode bits (644) and ownership (root:root), so that it becomes the default theme for new users. However QT apps don’t just equal KDE apps - as mentionned earlier - they also look slightly different inside and outside of KDE, and qtconfig behaves differently. When started under KDE, you can not change the color palette - the program says “Please use the KDE Control Center to set the palette” - while you can tune the palette outside of KDE and the changes get saved in ~/.config/Trolltech.conf. I don’t program in QT, but I could imagine that whether your applications can use the theme define in ~/.config/Trolltech.conf is a question of implementation on your side.

If I’m not mistaken, this is an end-user setting. Can I tell my app to use the KDE look if it’s being run inside KDE?