[Solved] Qt 4.8.3 GUI application on Linux looks old/unstyled and doesn't match the designer preview
-
I installed Qt 4.8.3 and Qt Creator 2.5.2 on Fedora 17 and Ubuntu 12.04. When I create a GUI application, the visual elements look good in the Qt Designer preview window. However when I run the application, the resulting application has an older style which is inconsistent with the OS and does not match the preview in Qt Designer.
In both of the images below, the top part is the preview from Qt Designer and the bottom part is the compiled application.
- Qt was installed by compiling the source located at http://qt-project.org/downloads
- During ./configure phase of the installation, the "open source" version was chosen.
- This issue occurs whether the application is run from the OS or launched from the IDE
Is there a way to make the compiled GUI application appear properly?
Fedora:
- Top Half = Qt Designer preview (desired)
- Bottom Half = resulting application
!http://i.stack.imgur.com/h2Z6l.png(Image depicting Fedora GUI styling)!
Ubuntu:
- Top Half = Qt Designer preview (desired)
- Bottom Half = resulting application
!http://i.stack.imgur.com/agPAs.png(Image depicting Ubuntu GUI styling)!
-
You need to set the style to be used by your app. You can do it at runtime by calling your application with -style <name of the style>. You can read more about this in the "documentation":http://qt-project.org/doc/qt-4.8/qstyle.html.
-
Are you running the application as the same user that runs the designer?
Other users will most likely have a different styling set up (or none at all). This happens a lot when people run UI apps as root via sudo.
-
Yes, I think that the problem is with which user you run the application and the graphics effects of your system. The root and other users have not the same graphics effects !
-
sierdzio:
This issue didn't occur on previous versions of Qt (such as 4.8.1). Has this recently changed in this version? I thought the default settings are supposed to match the style of the OS.Tobias Hunger:
I didn't think of that. I just tried it now by double clicking the application via gnome and it still appears the same. I also opened up terminal, made sure I was logged in as me, and launched it that way, still no go.I wonder if it's an issue with my OS'es so I'll try to reinstall 4.8.1 and see if it still happens. Perhaps it was always like this and I'm just noticing it now? Maybe I'm going crazy haha.
-
I tried a few more things thanks to your ideas but none of them yielded favourable results:
-
Made sure the owner and group were set to my user, not root. They were indeed set to my user.
-
I thought perhaps it didn't have certain libraries, so I copied the application to the Qt SDK lib folder and ran it from there. The location of the lib folder is the default one: /usr/local/Trolltech/Qt-4.8.3/lib
-
-
Here are some interesting findings:
I installed Qt SDK 1.2.1 (Qt 4.8.1) on two different computers, where one of these computers also has Qt 4.8.3 and Creator 2.4.2 installed. Thus the total setup for the two computers are as follows:
Computer #1 (Qt 4.8.2 + Qt SDK 1.2.1)
- OS: Fedora 17
- Qt: 4.8.3 + 4.8.1
- Creator: 2.4.2 + 2.4.1
- qt-x11 package: qt-x11-4.8.2-7.fc17.i686
Computer #2 (Qt SDK 1.2.1 only)
- OS: Fedora 17
- Qt: 4.8.1
- Creator: 2.4.1
- qt-x11 package: qt-x11-4.8.2-7.fc17.i686
Notice that the installed OS packages are the same, which is also the latest available on the fedora repo.
On Computer #1, the error still occurs even though the application is compiled with 4.8.1.
On Computer #2, the error does not occur. But there is an error message upon launching the application: "QGtkStyle was unable to detect the current GTK+ theme.". Computer #2 is the preferable outcome.
Here are images of the results:
Computer #1 (Still not working)
!http://i.stack.imgur.com/RGtmY.png(4.8.3 + 4.8.1 doesn't work)!Computer #2 (Working)
!http://i.stack.imgur.com/Elq6q.png(4.8.1 alone does work)! -
Here is a hypothesis I have which might explain the situation:
Perhaps the installed system binaries are conflicting with the 4.8.3 binaries.
For example, latest version Fedora Qt binary is 4.8.2 (qt-x11), and the latest version of the Ubuntu Qt binaries is 4.8.1 (libqt4-gui).
However, I already tried running the application within the lib folder of Qt 4.8.3. Shouldn't it have attempted to load those libraries instead of the system libraries in that case?
I'll try to uninstall the system packages and copy the binaries found in the lib folder.
-
I removed the system qt library which I got from the OS repo (yum remove qt-x11) but the problem persists.
I traced the dependencies and it seems to be accessing the right libraries.
Perhaps a different dependency is outdated?Here is the output from the command: # ldd myApp
@ linux-gate.so.1 => (0xb77b8000)
libQtGui.so.4 => /usr/local/Trolltech/Qt-4.8.3/lib/libQtGui.so.4 (0xb6c73000)
libQtCore.so.4 => /usr/local/Trolltech/Qt-4.8.3/lib/libQtCore.so.4 (0xb6978000)
libpthread.so.0 => /lib/libpthread.so.0 (0x4b429000)
libstdc++.so.6 => /lib/libstdc++.so.6 (0x45287000)
libm.so.6 => /lib/libm.so.6 (0x4b46f000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x4b93d000)
libc.so.6 => /lib/libc.so.6 (0x4b275000)
libXext.so.6 => /lib/libXext.so.6 (0x4b929000)
libX11.so.6 => /lib/libX11.so.6 (0x4b7cb000)
libdl.so.2 => /lib/libdl.so.2 (0x4b445000)
librt.so.1 => /lib/librt.so.1 (0x4b44c000)
/lib/ld-linux.so.2 (0x4b252000)
libxcb.so.1 => /lib/libxcb.so.1 (0x4b905000)
libXau.so.6 => /lib/libXau.so.6 (0x4b7c5000)
@As you can see, it is accessing the right Qt libraries located at /usr/local/Trolltech/Qt-4.8.3/lib.
-
I further narrowed down the problem.
I made a mistake in one of my assumptions above. When both the SDK version of 4.8.1 and library version of 4.8.3 were both installed, the SDK 4.8.1 version was functional.
I then proceeded to install the library version of 4.8.1 (qt-everywhere-opensource-src-4.8.1.tar.gz) but the same problem occurred, compiled applications were not appearing properly.
I am certain now that I am not installing the Qt 4.8.3 library version properly (qt-everywhere-opensource-src-4.8.3.tar.gz)
Can someone check if I'm installing it correctly? I was following the steps that was in the docs but this was not enough to install it:
Install basic development tools
fedora: yum install @development-tools
ubuntu: apt-get install build-essentialInstall libXext-devel, otherwise ./configure will fail without it
./configure
make
make install
What am I missing?
-
I found http://qt-project.org/wiki/Build_Qt_For_Linux which includes a list of all dependencies to build Qt.
This list should probably be included in the build instructions which came with the source. I'll try these out and mark this issue as solved if it works. -
Problem is solved.
When installing the Qt source, the instructions forgot to mention that a list of developer libraries must be installed prior to the ./configure step. This list can be found here: http://qt-project.org/wiki/Build_Qt_For_Linux
Additionally, I had trouble compiling QtWebkit because of the error:
bq. g++: error: unrecognized command line option ‘-fuse-ld=gold’
To solve this new problem, one of the two following solutions are possible:
- At the configure step, run configure with the -no-webkit option: ./configure -no-webkit
OR
- Remove the line QMAKE_LFLAGS+=-fuse-ls-gold from the file /qt-everywhere.../src/3rdparty/webkit/Source/common.pri