You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

CMake编译Kate源码时QWidgetAction未声明错误求助

Fixing the QWidgetAction Undeclared Error When Compiling Kate

Hey Pablo, sorry to hear you're stuck on compiling Kate—let's get this sorted out. The error you're seeing ('QWidgetAction' was not declared in this scope) points to a missing link to Qt's Widgets module, even though you've installed most dependencies. Here's how to fix it:

1. Simplify Your CMake Command

Your current CMake command has manual Qt path overrides (TARGET_include_directories, Qt5_INCLUDE_DIRS, etc.) that are likely interfering with CMake's automatic Qt module detection. CMake is designed to find Qt on its own when the right packages are installed, so strip those out. Use this instead:

#! /bin/bash
cmake \
  -D CMAKE_BUILD_TYPE=RelWithDebInfo \
  -D CMAKE_INSTALL_PREFIX=~/kde/usr \
  -D KDE_INSTALL_USE_QT_SYS_PATHS:BOOL=ON \
  ../kate/

2. Verify the QtWidgets Development Package is Installed

While qtbase5-dev should include QtWidgets, it's worth double-checking that the specific widgets dev package is present (sometimes dependencies can get messed up):

sudo apt install libqt5widgets5-dev

3. Clean Up and Rebuild from Scratch

Old build cache can cause weird lingering issues. Wipe your build directory and start fresh:

# Replace "build" with your actual build directory name if different
rm -rf build/
mkdir build && cd build
# Run the simplified CMake command above
make
make install

4. Check for Missing Include (If the Above Fails)

In rare cases, the katesqlview.cpp file might be missing the necessary include for QWidgetAction. Open /home/pablo/kde/kate/addons/katesql/katesqlview.cpp and add this line at the top with the other includes:

#include <QWidgetAction>

Then re-run make.

As a side note: If your original Kate issue was just the missing ~/.config/kate folder, you could also try creating a new one (Kate will generate default configs on launch) or copying the default config from /usr/share/kate/ to your home directory, but since you're set on compiling, focusing on the above steps should get you past the error.

内容的提问来源于stack exchange,提问作者Pablo

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.29 08:21:46