-
Notifications
You must be signed in to change notification settings - Fork 215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Native look for Qt applications on Gtk systems #88
Comments
Need to find out why the Ubuntu global menu works for one of the Qt-based AppImages mentioned there but not for the others: http://forum.freecadweb.org/viewtopic.php?f=10&t=15525&start=30#p152606 Update: Adding the appmenu-qt5 or appmenu-qt (for Qt 4 apps) package to the ingredients should improve it for Ubuntu. |
Also see AppImage/AppImageKit#125 (comment) (Qt Platform Theme integration plugins for the KDE Plasma workspaces. Unofficial mini version). |
See https://github.com/MartinBriza/adwaita-qt to make it look native on GTK. |
On Ubuntu, |
Just side note. Do we have confirmed if Then if you restart application, the icons for buttons/menus are not loaded correctly. When I use the app outside of AppImage (e.g. I install it with distro package manager), everything works. Is |
Neither |
This worked with LXImage-QT on XFCE Vanilla:
And run:
And the GTK theme is used instead of Fusion Maybe a Script checking for Desktop Environment? |
QIcon::fromTheme(..) only worked with QT5ct for me |
With which exact AppImage is this working for you? Please provide a URL so that I can test. This would be a big step forward. Thanks. |
@probonopd OK, will do tonight. It is just weird. |
Btw, just to mention. Flatpak'ed version of the same application does not suffer from the problem. |
From https://community.kde.org/Guidelines_and_HOWTOs/Flatpak#Styles_and_integration_with_other_desktops I deduce that when creating an AppImage, one might consider to bundle
inside the AppImage. What I am not sure about, though, is why all of this is apparently needed for Qt 5 when in fact in earlier versions of Qt it was "just working", and widgets looked like Gtk+ widgets on Gtk+ systems. What is also not clear to me is the relationship between this issue and Qt vs. KDE and Gtk+ vs. GNOME. What I am looking for is the best way to make all Qt applications (including, but not limited to, KDE ones) look native on Gtk+ systems (including, but not limited to, GNOME ones). |
According to Qt's documentation
I ended up writing a wrapper script that improve (not resovle, KDE dialogs on some system are not native) native look. FILE_TO_RUN.wrapper #!/bin/sh
# clear LD_LIBRARY_PATH (set from AppRun)
# without clear "qtpaths --plugin-dir" returns $HERE/usr/lib
OLD_LD_LIBRARY_PATH="${LD_LIBRARY_PATH}"
export LD_LIBRARY_PATH=
SELF="`readlink -f "${0}"`"
EXEC="${SELF%.wrapper}"
HERE="${SELF%/*}"
QT_PLUGIN_PATH="${HERE}/../plugins"
PLUGINS_KF5="`kf5-config --qt-plugins 2>/dev/null`"
[ ! -z ${PLUGINS_KF5} ] && QT_PLUGIN_PATH="${QT_PLUGIN_PATH}:${PLUGINS_KF5}"
PLUGINS_QT5="`qtpaths --plugin-dir 2>/dev/null`"
[ ! -z ${PLUGINS_QT5} ] && [ "${PLUGINS_QT5}" != "${PLUGINS_KF5}" ] && QT_PLUGIN_PATH="${QT_PLUGIN_PATH}:${PLUGINS_QT5}"
export QT_PLUGIN_PATH
export LD_LIBRARY_PATH="${OLD_LD_LIBRARY_PATH}"
exec "${EXEC}" "${@}" [Desktop Entry] Note |
Thanks @sandman7920, that is very clever. Maybe this should be added to https://cgit.kde.org/scratch/brauch/appimage-exec-wrapper.git/ (discussed at AppImage/AppImageKit#396)? |
From Qt 5.6+ full version definition is embedded in library. objdump -p libQt5Gui.so.5
|
This was bug inside application.AppImage, not runtime |
This is a nightmare, on some system "KDEPlasmaPlatformTheme.so" cannot be loaded due QImage ABI change, on some is loaded and finally on
|
Progress. For gtk "platformthemes/libqgtk3.so" plugin must be bundled (preferred from qt.io) For KDE "platformthemes/KDEPlasmaPlatformTheme.so" (do not bundle this plugin) libQt5Concurrent.so.5 must be bundled I will attach list with all libraries used by KDE plugins (extracted from Arch). Maybe will be a good idea linuxdeployqt to have something like -bundle-kde-deps Note: On clean ubuntu/kubuntu install qtpaths returns could not find a Qt installation of kde_qt5_theme_list.txt |
Hi @sandman7920 that looks awesome. Can you achieve the same result when using Qt from https://launchpad.net/~beineri? |
All Qt version should be fine as long they are newer than Qt on client machine. new wrapper To run cd AppDir
cp /some/path/appimage.qt5run usr/bin/MyQt5Executable.qt5run
ln -s usr/bin/MyQt5Executable.qt5run AppRun This is c++ wrapper linked with Qt 5.1.1. main.cpp #include <QCoreApplication>
#include <QStringList>
#include <iostream>
#include <string>
#include <unistd.h>
int main(int /*argc*/, char *argv[], char **envp) {
char *real_path;
char *appDir = getenv("APPDIR");
if (appDir != nullptr) {
real_path = realpath(std::string(appDir).append("/AppRun").c_str(), nullptr);
} else {
real_path = realpath(argv[0], nullptr);
}
if (real_path == nullptr) return 1;
const std::string self(real_path);
size_t pos = self.find(".qt5run");
if (pos == std::string::npos) return 1;
real_path[pos] = '\0';
argv[0] = real_path;
pos = self.find_last_of('/');
const std::string appPath = (pos != std::string::npos) ? self.substr(0, pos) : "";
std::string qt_plugins = std::string(appPath).append("/../plugins");
for (auto const &qstring: QCoreApplication::libraryPaths()) {
qt_plugins.push_back(':');
qt_plugins.append(qstring.toStdString());
}
setenv("QT_PLUGIN_PATH", qt_plugins.c_str(), 1);
if (getenv("QT5_DEBUG_RUN") != nullptr) {
std::cerr << "QT_PLUGIN_PATH: " << qt_plugins << '\n'
<< "EXECUTABLE: " << argv[0] << std::endl;
}
return execve(argv[0], argv, envp);
} CMakeLists.txt cmake_minimum_required(VERSION 2.8)
project(AppImageQt5run)
set(APP_NAME "appimage.qt5run")
set(CMAKE_SKIP_BUILD_RPATH TRUE)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/bin")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11 -fPIC -DQT_CORE_LIB")
if(LINK_RUNTIME)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++")
endif()
set(QT_ROOT "${CMAKE_CURRENT_LIST_DIR}/Qt_5.1.1")
include_directories(SYSTEM ${QT_ROOT}/include)
include_directories(SYSTEM ${QT_ROOT}/include/QtCore)
link_directories(${QT_ROOT}/lib)
add_executable(${APP_NAME} "main.cpp")
target_link_libraries(${APP_NAME} -Wl,--rpath-link=${QT_ROOT}/lib -lQt5Core) |
Can you make an AppImage of an example Qt application on Travis CI using Qt from https://launchpad.net/~beineri? |
Tomorrow :) |
Last wrapper has fundamental logic error. |
That, of course, is not something we can assume. Looking forward to the sample app, but no hurries. |
https://github.com/sandman7920/Qt5Demo This demo is build on Ubuntu 16.04 with libraries from https://launchpad.net/~beineri/+archive/ubuntu/opt-qt-5.10.1-xenial I have build demos with Qt 5.10.1 on purpose. One can see the difference running demos on Qt libraries from qt.io have less external dependencies objdump -p qt_io/5.11.0/libQt5Gui.so.5|grep NEEDED
NEEDED libQt5Core.so.5
NEEDED libpthread.so.0
NEEDED libGL.so.1
NEEDED libz.so.1
NEEDED libstdc++.so.6
NEEDED libm.so.6
NEEDED libgcc_s.so.1
NEEDED libc.so.6 objdump -p /usr/lib/libQt5Gui.so.5|grep NEEDED NEEDED libQt5Core.so.5
NEEDED libpthread.so.0
NEEDED libGL.so.1
NEEDED libpng16.so.16
NEEDED libharfbuzz.so.0
NEEDED libz.so.1
NEEDED libstdc++.so.6
NEEDED libm.so.6
NEEDED libgcc_s.so.1
NEEDED libc.so.6 |
Interesting find!
What happens if you bundle the KDE look&feel plugin but NOT its dependencies? |
I have rebuild |
Can you track them down? What is crashing, and why? |
is there any way to preserve |
Looks like to achieve the same result but with newer Qt, we need to find and use the GTK2 style and the GTK2 platform theme. What a shame that this is no longer "just working" by default. https://askubuntu.com/a/910143/545939 says:
https://askubuntu.com/questions/706528/qt-apps-stopped-inheriting-gtk-themes/748186#748186 says:
|
Isn't |
qt5ct is a platform theme:
|
Interesting, I was not aware of that. Yes, then should be possible to bundle this platform theme and style using Also see probonopd/linuxdeployqt#60 Do you have a screenshot of how libqt5ct looks on e.g., a Xfce system? |
Does this mean that it is using other, existing themes and styles internally? Then those would need to be bundled as well, I guess. |
as input it is using config from so, in order for application to use qt5ct it should be bundled with application itself? |
You mean |
yes, sorry, i mistyped and not included it's not needed for my own app, i just was wondering is it something to report to app's packager or it can be solved on a user side |
The application developer who makes an AppImage (or, more generally, "bundles a private copy of Qt with the application") needs to also bundle and configure qt5ct. How exactly this works would need to be asked from the qt5ct devs. |
Hi, what is the progress on this? |
While trying to make Qt application look like Gtk applications is doable, we have concluded that it is currently not worth the effort. Pulling Gtk stuff into AppImages that could otherwise be Gtk free introduces too many potential pitfalls, so we are no longer trying to do it. Also, Gtk is moving into the direction of an ever-changing "moving target" with no obvious ABI compatibility guarantees, which makes it is very hard to support. |
We should try to make Qt applications look native.
https://bugreports.qt.io/browse/QTBUG-53844
https://forum.manjaro.org/t/solved-qt-apps-theming-broken-after-last-nights-update/6471
The text was updated successfully, but these errors were encountered: