我的 qt6 应用程序在使用 qt6.7.2 sdk 构建并安装了 qt 的官方
.run
文件时运行良好,并且该应用程序使用了 sdk 中的 .so
库。然后我删除了 sdk 并使用 archlinux 官方存储库中的 qt6.8 重建了我的应用程序。然后我发现当我用 kf.statusnotifieritem: env says KDE is running but SNI unavailable -- check KDE_FULL_SESSION and XDG_CURRENT_DESKTOP
运行它时它告诉我 sudo
并且无法显示托盘图标,而当我以普通用户运行它时它可以正常工作。
export QT_PLUGIN_PATH=/usr/lib/qt6/plugins/
无法使其正常工作。
我以前遇到过这样的错误,是否不建议以root身份运行qt应用程序?我该如何修复它,或者我最好不要以 root 身份运行 GUI qt 应用程序?谢谢。
我的
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)
输出
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
最终解决方案是
unset XDG_CURRENT_DESKTOP
或export XDG_CURRENT_DESKTOP=""
。