当前位置:网站首页>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.
边栏推荐
猜你喜欢
随机推荐
Class template case - encapsulation of array classes
[mask RCNN] target detection and recognition based on mask RCNN
【Hot100】11. 盛最多水的容器
June 29, 2022 -- take the first step with C # -- add decision logic to the code using the "if", "else" and "else if" statements in C #
如果我在珠海,到哪里开户比较好?另外,手机开户安全么?
【Mask-RCNN】基于Mask-RCNN的目标检测和识别
QT signal slot alarm QObject:: connect:cannot connect (null)
免实名域名是什么意思?
Problems and solutions of creating topic messages in ROS
1285_把AUTOSAR函数以及变量等定义的宏用脚本展开以提高可读性
Mysql5.7 compressed version installation tutorial
Introduction to go project directory structure
Qstring to const char*
安装Go语言开发工具
Cmake post makefile:32: * * * missing separator Stop.
ftplib+ tqdm 上传下载进度条
How does the CPU recognize the code?
RT thread Kernel Implementation (II): critical area, object container
freemarker
Browser downloads files as attachments









![[docsify basic use]](/img/9d/db689f5f13708f3e241474afeca1d0.png)