My qt6 app worked well when built with a qt6.7.2 sdk installed with qt's official .run
file, and the app used .so
library from the sdk. Then I removed the sdk and rebuilt my app with qt6.8 from archlinux official repository. Then I found that it tells me kf.statusnotifieritem: env says KDE is running but SNI unavailable -- check KDE_FULL_SESSION and XDG_CURRENT_DESKTOP
when I run it with sudo
and fails to show tray icon, while it works correctly when I run it as normal user.
export QT_PLUGIN_PATH=/usr/lib/qt6/plugins/
does not make it work well.
I have met with such error before, is it not recommended to run qt app as root? How can I fix it or I had better not run GUI qt app as root? Thanks.
My CMakeLists.txt
:
cmake_minimum_required(VERSION 3.21)
project(myproject VERSION 2.1.0 LANGUAGES CXX)
set(CMAKE_BUILD_TYPE "Debug")
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)
set(CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS on)
include_directories("include")
IF (CMAKE_SYSTEM_NAME MATCHES "Linux")
include_directories("/usr/include/qt6/")
set(CMAKE_PREFIX_PATH "/usr/lib/cmake/")
ELSEIF (CMAKE_SYSTEM_NAME MATCHES "Windows")
#
ENDIF (CMAKE_SYSTEM_NAME MATCHES "Linux")
if(CMAKE_BUILD_TYPE MATCHES "Release")
add_definitions(-DQT_NO_DEBUG_OUTPUT)
endif()
find_package(Qt6 REQUIRED COMPONENTS Core Widgets Gui)
add_executable(myproject main.cpp myproject.cpp myproject.qrc myproject.rc config.ui monitor.ui)
target_link_libraries(myproject PRIVATE Qt6::Core Qt6::Widgets Qt6::Gui)
output of pacman -Q |grep qt
appstream-qt 1.0.3-1
bluez-qt 6.7.0-1
fcitx5-qt 5.1.8-1
kdsoap-qt6 2.2.0-1
layer-shell-qt 6.2.2-1
libaccounts-qt 1.17-1
liblastfm-qt5 1.1.0-1
libmygpo-qt5 1.1.0-3
libqaccessibilityclient-qt6 0.6.0-1
modemmanager-qt 6.7.0-1
networkmanager-qt 6.7.0-1
phonon-qt6 4.12.0-4
phonon-qt6-vlc 0.12.0-2
polkit-qt6 0.200.0-1
poppler-qt6 24.09.0-4
pulseaudio-qt 1.6.0-1
qca-qt6 2.3.9-3
qt5-base 5.15.15+kde+r132-1
qt5-declarative 5.15.15+kde+r25-1
qt5-location 5.15.15+kde+r7-1
qt5-multimedia 5.15.15+kde+r2-1
qt5-svg 5.15.15+kde+r5-1
qt5-tools 5.15.15+kde+r3-2
qt5-translations 5.15.15-1
qt5-wayland 5.15.15+kde+r60-1
qt5-webchannel 5.15.15+kde+r3-1
qt5-webengine 5.15.17-7
qt5-x11extras 5.15.15-1
qt6-5compat 6.8.0-1
qt6-base 6.8.0-1
qt6-charts 6.8.0-1
qt6-declarative 6.8.0-2
qt6-imageformats 6.8.0-1
qt6-multimedia 6.8.0-1
qt6-multimedia-ffmpeg 6.8.0-1
qt6-positioning 6.8.0-1
qt6-quick3d 6.8.0-1
qt6-quicktimeline 6.8.0-1
qt6-sensors 6.8.0-1
qt6-shadertools 6.8.0-1
qt6-speech 6.8.0-1
qt6-svg 6.8.0-1
qt6-tools 6.8.0-1
qt6-translations 6.8.0-1
qt6-virtualkeyboard 6.8.0-1
qt6-wayland 6.8.0-1
qt6-webchannel 6.8.0-1
qt6-webengine 6.8.0-5
qt6-websockets 6.8.0-1
qtkeychain-qt6 0.14.3-1
The final solution is to unset XDG_CURRENT_DESKTOP
or export XDG_CURRENT_DESKTOP=""
.