在qt5中使用XShapeCombineRectangles编译报错

linux x11环境中,在qt5中使用XShapeCombineRectangles去实现鼠标穿透

引用了两个头文件:

c++ 复制代码
#include <QX11Info>
#include <X11/extensions/shape.h>

编译的时候会报错:

Desktop_Qt_5_12_12_GCC_64bit-Debug/moc_mainwindow.cpp:86: error: expected unqualified-id before 'int'

In file included from /usr/include/X11/Xutil.h:53,

from /usr/include/X11/extensions/shape.h:34,

from .../tablet/mainwindow.h:58,

from moc_mainwindow.cpp:9:

moc_mainwindow.cpp:86:33: error: expected unqualified-id before 'int'

86 | QMetaType::Void, QMetaType::Bool, 9,

| ^~~~

根据报错信息,可查到是x11/xlib.h这个库中使用define定义了一些类型导致qt编译报错

https://stackoverflow.com/questions/22476110/c-compiling-error-including-x11-x-h-x11-xlib-h/41837372#41837372

根据stackoverflow中的答案,去掉用宏定义的类型即可成功编译:

c++ 复制代码
#include <QX11Info>
#include <X11/extensions/shape.h>

#undef Bool
#undef CursorShape
#undef Expose
#undef KeyPress
#undef KeyRelease
#undef FocusIn
#undef FocusOut
#undef FontChange
#undef None
#undef Status
#undef Unsorted
相关推荐
无聊的烤苕皮5 分钟前
RHCE(RHCSA复习:npm、dnf、源码安装实验)
linux·npm·云计算·dnf·rhcsa
哥谭居民000111 分钟前
mybatis注册一个自定义拦截器,拦截器用于自动填充字段
java·开发语言·jvm·mybatis
xxxx12344514 分钟前
Linux驱动开发-①pinctrl 和 gpio 子系统②并发和竞争③内核定时器
linux·驱动开发·单片机
stone082319 分钟前
ABAP语言的动态编程(4) - 综合案例:管理费用明细表
linux·运维·服务器
钟离墨笺20 分钟前
【c++】【智能指针】什么情况下不适合智能指针
开发语言·c++
AAA废品回收站陈师傅35 分钟前
1.Qt SDK 的下载和安装
qt
moz与京37 分钟前
【记】如何理解kotlin中的委托属性?
android·开发语言·kotlin
左少华42 分钟前
Kotlin-inline函数特效
android·开发语言·kotlin
懒大王爱吃狼43 分钟前
Python + Qt Designer构建多界面GUI应用程序:Python如何调用多个界面文件
开发语言·数据库·python·qt·mysql·python基础·命令模式
厂里英才43 分钟前
docker无法正常拉取镜像问题的解决
linux·docker