在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
相关推荐
辞旧 lekkk6 小时前
【Qt】信号和槽
linux·开发语言·数据库·qt·学习·mysql·萌新
2zcode7 小时前
运动模糊图像复原的MATLAB仿真与优化
开发语言·matlab
袁雅倩19977 小时前
当吸尘器、筋膜枪都用上Type-C,供电方案该怎么选?浅谈PD取电芯片ECP5702的应用
c语言·开发语言·支持向量机·动态规划·推荐算法·最小二乘法·图搜索算法
Aaswk8 小时前
Java Lambda 表达式与流处理
java·开发语言·python
万邦科技Lafite8 小时前
京东item_get接口实战案例:实时商品价格监控全流程解析
java·开发语言·数据库·python·开放api·淘宝开放平台
liuhuizuikeai9 小时前
可视化门禁---Linux/Qt+SqLite篇
linux·运维·qt
Cyber4K9 小时前
【Python专项】进阶语法-系统资源监控与数据采集(1)
开发语言·python·php
初願致夕霞9 小时前
基于系统调用的Linux网络编程——UDP与TCP
linux·网络·c++·tcp/ip·udp
Le_ee9 小时前
ctfweb:php/php短标签/.haccess+图片马/XXE
开发语言·前端·php
yong999010 小时前
MATLAB读取高光谱图像
开发语言·matlab