当前位置:网站首页>QT common macro definitions
QT common macro definitions
2022-06-30 07:04:00 【HL_ Aeolus】
This article mainly accumulates some commonly used macros Definition , Some definitions are in the header file QtGlobal in
- QT_VERSION ,QT_VERSION_CHECK
// It is mainly used for conditional compilation settings , according to Qt Different versions compile different code
// I used it here Qt The version is 5.7.1, So the branch of software is cc = 10000
Sample code :
#if QT_VERSION >= QT_VERSION_CHECK(5,7,2)
int cc = 0;
#else
int cc = 10000;
#endif
- QT_VERSION_STR
qDebug() << QT_VERSION_STR << endl;
3. Q_BYTE_ORDER,Q_BIG_ENDIAN,Q_LITTLE_ENDIAN
System memory data byte order , Indicates the size end
#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN // My platform is small end
qDebug() << "Q_LITTLE_ENDIAN" << endl;
#else
#endif
4. debug Output Disable setting macro QT_NO_DEBUG_OUTPUT, stay pro Add the following code to the file , All in the software QDebug Will fail
DEFINES += QT_NO_DEBUG_OUTPUT
- Q_UNUSED(valuename) Used for variables not used in functions , Tell the compiler that this variable does not require an alarm
Special , It can also be in pro Add the following code to the file to shield unused alarms
QMAKE_CXXFLAGS += -Wno-unused-parameter
Q_DECL_OVERRIDE After the function declaration for the class , Overloading a virtual function , If this macro is used , No overload operation was performed , The compiler will report an error
Q_DECL_FINAL Used to define a virtual function as the final level , Can no longer be overloaded , Or define a class that can no longer be inherited
class QPushButton Q_DECL_FINAL {
//QPushButton Can no longer be inherited
//...
};
Q_SIGNAL: Unwanted signals Keyword can specify a function as singal function
Q_SLOT: Unwanted slots Keyword can specify a function as slot function
qChecksum: The calculation is based on CRC-16-CCITT Algorithm CRC-16 Check code
qCompress/qUncompress: be based on zlib The algorithm compresses the byte buffer / decompression , You can customize the compression ratio
qDeleteAll: Each object in a container or iterator is delete operation
qRound/qRound64: Round floating point numbers , rounding
qFuzzyCompare: Fuzzy comparison of thread safe floating point numbers , The problem of floating-point precision error is solved
qVersion: Get the currently running Qt Version number of
QSysInfo: Get the current running system information , Including version number, etc ,Mac/Symbian/Windows All apply
QtEndian: Handle the problem of different byte storage order under different architectures
QObject::findChildren<>: Find hidden sub objects
qobject_cast: No compiler needed RTTI With the support of C++ Standard library dynamic_cast The function of
QObject::deleteLater: Call... In the event handling loop , Delete yourself at the end of the event processing cycle ; Call... Outside the event handling loop , Delete yourself at the beginning of the next event processing cycle
qPrintable: similar QString::toLocal8Bit()::constData(), But it's better to remember
connect(SomeObj, SIGNAL(foo()), SIGNAL(bar()): Through one signal Automatically trigger another signal.
边栏推荐
猜你喜欢
随机推荐
How to convert XML to JSON
Problems and solutions of creating topic messages in ROS
Linux服务器安装Redis
oracle数据库报列表中最大表达式为1000错误
[docsify basic use]
Egret P2 pit encountered by physical engine (1)
Google Earth Engine(GEE)——墨累全球潮汐湿地变化 v1 (1999-2019) 数据集
Go常用命令
SQL Server2005中SUM函数内嵌套IF语句
Performance comparison of random network, scale-free network, small world network and NS small world matlab simulation
The solution of memcpy memory overlap
Linux server installation redis
安装setup对应的组件
RT thread migration to s5p4418 (I): scheduler
ftplib+ tqdm 上传下载进度条
Introduction to go project directory structure
Skillfully use 5 keys to improve office efficiency
经纬恒润再次荣获PACCAR集团 10PPM 质量奖
15 minutes learn to use JWT
Egret engine P2 physics engine (2) - Funny physical phenomenon of small balls hitting the ground