在QtGobal中有近百个内置全局定义,常用的大概二十余个,分成Types数据类型、Functions函数、Macros宏定义,代码敲累了整理学习一波还是很有必要的
文档地址:https://doc.qt.io/qt-5/qtglobal.html#QFunctionPointer-typedef
类型 | 函数名 | 功 能 |
T | qAbs(const T &t) | 返回变量t的绝对值 |
typename std::add_const<T>::type & | qAsConst(T &t) | 将返回值强制转换成T |
void | qAsConst(const T &&t) | 重载函数,删除此重载防止代码中的悬挂引用 |
const T & | qBound(const T &min, const T &val, const T &max) | 返回值介于min和max之间 |
auto | qConstOverload(T memberFunctionPointer) | 返回指向恒定成员参数memberFunctionPointer的指针 |
QString | qEnvironmentVariable(const char *varName) | |
QString | qEnvironmentVariable(const char *varName, const QString &defaultValue) | |
int | qEnvironmentVariableIntValue(const char *varName, bool *ok = nullptr) | |
bool | qEnvironmentVariableIsEmpty(const char *varName) | |
bool | qEnvironmentVariableIsSet(const char *varName) | |
T | qExchange(T &obj, U &&newValue) | |
quint32 | qFloatDistance(float a, float b) | |
quint64 | qFloatDistance(double a, double b) | |
QString | qFormatLogMessage(QtMsgType type, const QMessageLogContext &context, const QString &str) | |
int | qFpClassify(double val) | |
bool | qFuzzyCompare(double p1, double p2) | 如果p1和p2近似相等,则返回true |
bool | qFuzzyCompare(float p1, float p2) | 如果p1和p2近似相等,则返回true |
bool | qFuzzyIsNull(double d) | 如果d约等于0,则返回true |
bool | qFuzzyIsNull(float f) | 如果d约等于0,则返回true |
double | qInf() | 返回无穷大的数 |
QtMessageHandler | qInstallMessageHandler(QtMessageHandler handler) | |
bool | qIsFinite(double d) | 如果d是一个有限的数,则返回true |
bool | qIsFinite(float f) | 如果f是一个有限的数,则返回true |
bool | qIsInf(double d) | 如果d是一个无限的数,则返回true |
bool | qIsInf(float f) | 如果f是一个无限的数,则返回true |
bool | qIsNaN(double d) | 如果d不是一个数,则返回true |
bool | qIsNaN(float f) | 如果f不是一个数,则返回true |
const T & | qMax(const T &a, const T &b) | 返回a、b中较大的数 |
const T & | qMin(const T &a, const T &b) | 返回a、b中较小的数 |
auto | qNonConstOverload(T memberFunctionPointer) | |
auto | qOverload(T functionPointer) | 返回指向重载函数的指针 |
double | qQNaN() | |
qint64 | qRound64(double d) | 返回与d最接近的qint64整数 |
qint64 | qRound64(float d) | 返回与f最接近的qint64整数 |
int | qRound(double d) | 返回与d最接近的int整数 |
int | qRound(float d) | 返回与d最接近的int整数 |
double | qSNaN() | |
void | qSetMessagePattern(const QString &pattern) | |
const char * | qVersion() | 返回版本号 |
T * | q_check_ptr(T *p) | |
QByteArray | qgetenv(const char *varName) | |
bool | qputenv(const char *varName, const QByteArray &value) | |
QString | qtTrId(const char *id, int n = ...) | |
bool | qunsetenv(const char *varName) |