<QtGlobal>
The <QtGlobal> header file includes the fundamental global declarations. It is included by most other Qt header files.
- #include <<QtGlobal>>
Detailed Description
The <QtGlobal> header file includes the fundamental global declarations. It is included by most other Qt header files.
The global declarations include types, functions and macros.
The type definitions are partly convenience definitions for basic types (some of which guarantee certain bit-sizes on all platforms supported by Qt), partly types related to Qt message handling. The functions are related to generating messages, Qt version handling and comparing and adjusting object values. And finally, some of the declared macros enable programmers to add compiler or platform specific code to their applications, while others are convenience macros for larger operations.
Types
The header file declares several type definitions that guarantee a specified bit-size on all platforms supported by Qt for various basic types, for example qint8 which is a signed char guaranteed to be 8-bit on all platforms supported by Qt. The header file also declares the qlonglong type definition for long long int (__int64 on Windows).
Several convenience type definitions are declared: qreal for double, uchar for unsigned char, uint for unsigned int, ulong for unsigned long and ushort for unsigned short.
Finally, the QtMsgType definition identifies the various messages that can be generated and sent to a Qt message handler; QtMsgHandler is a type definition for a pointer to a function with the signature void myMsgHandler(QtMsgType, const char *).
Functions
The <QtGlobal> header file contains several functions comparing and adjusting an object's value. These functions take a template type as argument: You can retrieve the absolute value of an object using the qAbs() function, and you can bound a given object's value by given minimum and maximum values using the qBound() function. You can retrieve the minimum and maximum of two given objects using qMin() and qMax() respectively. All these functions return a corresponding template type; the template types can be replaced by any other type.
Example:
- int myValue = 10;
- int minValue = 2;
- int maxValue = 6;
- int boundedValue = qBound(minValue, myValue, maxValue);
- // boundedValue == 6
<QtGlobal> also contains functions that generate messages from the given string argument: qCritical(), qDebug(), qFatal() and qWarning(). These functions call the message handler with the given message.
Example:
- if (!driver()->isOpen() || driver()->isOpenError()) {
- qWarning("QSqlQuery::exec: database not open");
- return false;
- }
The remaining functions are qRound() and qRound64(), which both accept a qreal value as their argument returning the value rounded up to the nearest integer and 64-bit integer respectively, the qInstallMsgHandler() function which installs the given QtMsgHandler, and the qVersion() function which returns the version number of Qt at run-time as a string.
Macros
The <QtGlobal> header file provides a range of macros (Q_CC_*) that are defined if the application is compiled using the specified platforms. For example, the Q_CC_SUN macro is defined if the application is compiled using Forte Developer, or Sun Studio C++. The header file also declares a range of macros (Q_OS_*) that are defined for the specified platforms. For example, Q_OS_X11 which is defined for the X Window System.
The purpose of these macros is to enable programmers to add compiler or platform specific code to their application.
The remaining macros are convenience macros for larger operations: The QT_TRANSLATE_NOOP() and QT_TR_NOOP() macros provide the possibility of marking text for dynamic translation, i.e. translation without changing the stored source text. The Q_ASSERT() and Q_ASSERT_X() enables warning messages of various level of refinement. The Q_FOREACH() and foreach() macros implement Qt's foreach loop.
The Q_INT64_C() and Q_UINT64_C() macros wrap signed and unsigned 64-bit integer literals in a platform-independent way. The Q_CHECK_PTR() macro prints a warning containing the source code's file name and line number, saying that the program ran out of memory, if the pointer is 0. The qPrintable() macro represent an easy way of printing text.
Finally, the QT_POINTER_SIZE macro expands to the size of a pointer in bytes, and the QT_VERSION and QT_VERSION_STR macros expand to a numeric value or a string, respectively, specifying Qt's version number, i.e the version the application is compiled against.
See also <QtAlgorithms> and QSysInfo.
Public Types
| Toggle details | enum :: | QtMsgTypeQtMsgType { QtDebugMsg , QtWarningMsg , QtCriticalMsg , QtFatalMsg , QtSystemMsg QtCriticalMsg ...} { QtDebugMsg , QtWarningMsg , QtCriticalMsg , QtFatalMsg , QtSystemMsg QtCriticalMsg } | ||||||||||||||||||
This enum describes the messages that can be sent to a message handler (QtMsgHandler). You can use the enum to identify and associate the various message types with the appropriate actions.
See also QtMsgHandler and qInstallMsgHandler(). | ||||||||||||||||||||
Look up this member in the source code. | ||||||||||||||||||||
Types
| Toggle details | typedef | QtMsgHandlerQtMsgHandler |
This is a typedef for a pointer to a function with the following signature:
See also QtMsgType and qInstallMsgHandler(). | ||
Look up this member in the source code. | ||
| Toggle details | typedef | qint8qint8 |
Typedef for signed char. This type is guaranteed to be 8-bit on all platforms supported by Qt. | ||
Look up this member in the source code. | ||
| Toggle details | typedef | qint16qint16 |
Typedef for signed short. This type is guaranteed to be 16-bit on all platforms supported by Qt. | ||
Look up this member in the source code. | ||
| Toggle details | typedef | qint32qint32 |
Typedef for signed int. This type is guaranteed to be 32-bit on all platforms supported by Qt. | ||
Look up this member in the source code. | ||
| Toggle details | typedef | qint64qint64 |
Look up this member in the source code. | ||
| Toggle details | typedef | qlonglongqlonglong |
Typedef for long long int (__int64 on Windows). This is the same as qint64. See also qulonglong and qint64. | ||
Look up this member in the source code. | ||
| Toggle details | typedef | qptrdiffqptrdiff |
Integral type for representing pointer differences. Typedef for either qint32 or qint64. This type is guaranteed to be the same size as a pointer on all platforms supported by Qt. On a system with 32-bit pointers, quintptr is a typedef for quint32; on a system with 64-bit pointers, quintptr is a typedef for quint64. Note that qptrdiff is signed. Use quintptr for unsigned values. | ||
Look up this member in the source code. | ||
| Toggle details | typedef | qrealqreal |
Typedef for double on all platforms except for those using CPUs with ARM architectures. On ARM-based platforms, qreal is a typedef for float for performance reasons. | ||
Look up this member in the source code. | ||
| Toggle details | typedef | quint8quint8 |
Typedef for unsigned char. This type is guaranteed to be 8-bit on all platforms supported by Qt. | ||
Look up this member in the source code. | ||
| Toggle details | typedef | quint16quint16 |
Typedef for unsigned short. This type is guaranteed to be 16-bit on all platforms supported by Qt. | ||
Look up this member in the source code. | ||
| Toggle details | typedef | quint32quint32 |
Typedef for unsigned int. This type is guaranteed to be 32-bit on all platforms supported by Qt. | ||
Look up this member in the source code. | ||
| Toggle details | typedef | quint64quint64 |
Typedef for unsigned long long int (unsigned __int64 on Windows). This type is guaranteed to be 64-bit on all platforms supported by Qt. Literals of this type can be created using the Q_UINT64_C() macro:
See also Q_UINT64_C(), qint64, and qulonglong. | ||
Look up this member in the source code. | ||
| Toggle details | typedef | quintptrquintptr |
Integral type for representing a pointers (useful for hashing, etc.). Typedef for either quint32 or quint64. This type is guaranteed to be the same size as a pointer on all platforms supported by Qt. On a system with 32-bit pointers, quintptr is a typedef for quint32; on a system with 64-bit pointers, quintptr is a typedef for quint64. Note that quintptr is unsigned. Use qptrdiff for signed values. | ||
Look up this member in the source code. | ||
| Toggle details | typedef | qulonglongqulonglong |
Look up this member in the source code. | ||
| Toggle details | typedef | ucharuchar |
Convenience typedef for unsigned char. | ||
Look up this member in the source code. | ||
| Toggle details | typedef | uintuint |
Convenience typedef for unsigned int. | ||
Look up this member in the source code. | ||
| Toggle details | typedef | ulongulong |
Convenience typedef for unsigned long. | ||
Look up this member in the source code. | ||
| Toggle details | typedef | ushortushort |
Convenience typedef for unsigned short. | ||
Look up this member in the source code. | ||
Public Functions
| Toggle details | T | qAbsqAbs ( const T &value ) ( const T &value ) |
Compares value to the 0 of type T and returns the absolute value. Thus if T is double, then value is compared to (double) 0. Example:
| ||
Look up this member in the source code. | ||
| Toggle details | const T & | qBoundqBound ( const T &min , const T &value , const T &max ...) ( const T &min , const T &value , const T &max ) |
Look up this member in the source code. | ||
| Toggle details | void | qCriticalqCritical ( const char *msg , ... ) ( const char *msg , ... ) |
Calls the message handler with the critical message msg. If no message handler has been installed, the message is printed to stderr. Under Windows, the message is sent to the debugger. This function takes a format string and a list of arguments, similar to the C printf() function. The format should be a Latin-1 string. Example:
If you include <QtDebug>, a more convenient syntax is also available:
A space is inserted between the items, and a newline is appended at the end. To suppress the output at runtime, install your own message handler with qInstallMsgHandler(). See also qDebug(), qWarning(), qFatal(), qInstallMsgHandler(), and Debugging Techniques. | ||
Look up this member in the source code. | ||
| Toggle details | void | qDebugqDebug ( const char *msg , ... ) ( const char *msg , ... ) |
Calls the message handler with the debug message msg. If no message handler has been installed, the message is printed to stderr. Under Windows, the message is sent to the console, if it is a console application; otherwise, it is sent to the debugger. This function does nothing if QT_NO_DEBUG_OUTPUT was defined during compilation. If you pass the function a format string and a list of arguments, it works in similar way to the C printf() function. The format should be a Latin-1 string. Example:
If you include <QtDebug>, a more convenient syntax is also available:
With this syntax, the function returns a QDebug object that is configured to use the QtDebugMsg message type. It automatically puts a single space between each item, and outputs a newline at the end. It supports many C++ and Qt types. To suppress the output at run-time, install your own message handler with qInstallMsgHandler(). See also qWarning(), qCritical(), qFatal(), qInstallMsgHandler(), and Debugging Techniques. | ||
Look up this member in the source code. | ||
| Toggle details | void | qFatalqFatal ( const char *msg , ... ) ( const char *msg , ... ) |
Calls the message handler with the fatal message msg. If no message handler has been installed, the message is printed to stderr. Under Windows, the message is sent to the debugger. If you are using the default message handler this function will abort on Unix systems to create a core dump. On Windows, for debug builds, this function will report a _CRT_ERROR enabling you to connect a debugger to the application. This function takes a format string and a list of arguments, similar to the C printf() function. Example:
To suppress the output at runtime, install your own message handler with qInstallMsgHandler(). See also qDebug(), qCritical(), qWarning(), qInstallMsgHandler(), and Debugging Techniques. | ||
Look up this member in the source code. | ||
| Toggle details | bool | qFuzzyCompareqFuzzyCompare ( double p1 , double p2 ) ( double p1 , double p2 ) [static] |
Compares the floating point value p1 and p2 and returns true if they are considered equal, otherwise false. Note that comparing values where either p1 or p2 is 0.0 will not work. The solution to this is to compare against values greater than or equal to 1.0.
The two numbers are compared in a relative way, where the exactness is stronger the smaller the numbers are. | ||
Look up this member in the source code. | ||
| Toggle details | bool | qFuzzyCompareqFuzzyCompare ( floatp1 , floatp2 ) ( floatp1 , floatp2 ) [static] |
Compares the floating point value p1 and p2 and returns true if they are considered equal, otherwise false. The two numbers are compared in a relative way, where the exactness is stronger the smaller the numbers are. | ||
Look up this member in the source code. | ||
| Toggle details | QtMsgHandler | qInstallMsgHandlerqInstallMsgHandler ( QtMsgHandler handler ...) ( QtMsgHandler handler ) |
Installs a Qt message handler which has been defined previously. Returns a pointer to the previous message handler (which may be 0). The message handler is a function that prints out debug messages, warnings, critical and fatal error messages. The Qt library (debug mode) contains hundreds of warning messages that are printed when internal errors (usually invalid function arguments) occur. Qt built in release mode also contains such warnings unless QT_NO_WARNING_OUTPUT and/or QT_NO_DEBUG_OUTPUT have been set during compilation. If you implement your own message handler, you get total control of these messages. The default message handler prints the message to the standard output under X11 or to the debugger under Windows. If it is a fatal message, the application aborts immediately. Only one message handler can be defined, since this is usually done on an application-wide basis to control debug output. To restore the message handler, call qInstallMsgHandler(0). Example:
See also qDebug(), qWarning(), qCritical(), qFatal(), QtMsgType, and Debugging Techniques. | ||
Look up this member in the source code. | ||
| Toggle details | int | qMacVersionqMacVersion () () |
Use QSysInfo::MacintoshVersion instead. See also QSysInfo. | ||
Look up this member in the source code. | ||
| Toggle details | const T & | qMaxqMax ( const T &value1 , const T &value2 ) ( const T &value1 , const T &value2 ) |
Look up this member in the source code. | ||
| Toggle details | const T & | qMinqMin ( const T &value1 , const T &value2 ) ( const T &value1 , const T &value2 ) |
Look up this member in the source code. | ||
| Toggle details | qint64 | qRound64qRound64 ( qreal value ) ( qreal value ) |
Rounds value to the nearest 64-bit integer. Example:
| ||
Look up this member in the source code. | ||
| Toggle details | int | qRoundqRound ( qreal value ) ( qreal value ) |
Rounds value to the nearest integer. Example:
| ||
Look up this member in the source code. | ||
| Toggle details | const char * | qVersionqVersion () () |
Returns the version number of Qt at run-time as a string (for example, "4.1.2"). This may be a different version than the version the application was compiled against. See also QT_VERSION_STR. | ||
Look up this member in the source code. | ||
| Toggle details | void | qWarningqWarning ( const char *msg , ... ) ( const char *msg , ... ) |
Calls the message handler with the warning message msg. If no message handler has been installed, the message is printed to stderr. Under Windows, the message is sent to the debugger. This function does nothing if QT_NO_WARNING_OUTPUT was defined during compilation; it exits if the environment variable QT_FATAL_WARNINGS is defined. This function takes a format string and a list of arguments, similar to the C printf() function. The format should be a Latin-1 string. Example:
If you include <QtDebug>, a more convenient syntax is also available:
This syntax inserts a space between each item, and appends a newline at the end. To suppress the output at runtime, install your own message handler with qInstallMsgHandler(). See also qDebug(), qCritical(), qFatal(), qInstallMsgHandler(), and Debugging Techniques. | ||
Look up this member in the source code. | ||
| Toggle details | T * | q_check_ptrq_check_ptr ( T *pointer ) ( T *pointer ) |
Users Q_CHECK_PTR on pointer, then returns pointer. This can be used as an inline version of Q_CHECK_PTR. | ||
Look up this member in the source code. | ||
| Toggle details | QByteArray | qgetenvqgetenv ( const char *varName ) ( const char *varName ) |
Returns the value of the environment variable with name varName. To get the variable string, use QByteArray::constData(). Note: qgetenv() was introduced because getenv() from the standard C library was deprecated in VC2005 (and later versions). qgetenv() uses the new replacement function in VC, and calls the standard C library's implementation on all other platforms. See also qputenv(). | ||
Look up this member in the source code. | ||
| Toggle details | bool | qputenvqputenv ( const char *varName , const QByteArray &value ...) ( const char *varName , const QByteArray &value ) |
This function sets the value of the environment variable named varName. It will create the variable if it does not exist. It returns 0 if the variable could not be set. Note: qputenv() was introduced because putenv() from the standard C library was deprecated in VC2005 (and later versions). qputenv() uses the replacement function in VC, and calls the standard C library's implementation on all other platforms. See also qgetenv(). | ||
Look up this member in the source code. | ||
| Toggle details | int | qrandqrand () () |
Thread-safe version of the standard C++ rand() function. Returns a value between 0 and RAND_MAX (defined in <cstdlib> and <stdlib.h>), the next number in the current sequence of pseudo-random integers. Use qsrand() to initialize the pseudo-random number generator with a seed value. See also qsrand(). | ||
Look up this member in the source code. | ||
| Toggle details | void | qsrandqsrand ( uint seed ) ( uint seed ) |
Thread-safe version of the standard C++ srand() function. Sets the argument seed to be used to generate a new random number sequence of pseudo random integers to be returned by qrand(). The sequence of random numbers generated is deterministic per thread. For example, if two threads call qsrand(1) and subsequently calls qrand(), the threads will get the same random number sequence. See also qrand(). | ||
Look up this member in the source code. | ||
| Toggle details | QString | qtTrIdqtTrId ( const char *id , int n=-1 ) ( const char *id , int n=-1 ) |
The qtTrId function finds and returns a translated string. Returns a translated string identified by id. If no matching string is found, the id itself is returned. This should not happen under normal conditions. If n >= 0, all occurrences of %n in the resulting string are replaced with a decimal representation of n. In addition, depending on n's value, the translation text may vary. Meta data and comments can be passed as documented for QObject::tr(). In addition, it is possible to supply a source string template like that: //% <C string> or /*% <C string> */ Example:
Creating QM files suitable for use with this function requires passing the -idbased option to the lrelease tool. Warning: This method is reentrant only if all translators are installed before calling this method. Installing or removing translators while performing translations is not supported. Doing so will probably result in crashes or other undesirable behavior. See also QObject::tr(), QCoreApplication::translate(), and Internationalization with Qt. | ||
Look up this member in the source code. | ||
| Toggle details | void | qt_set_sequence_auto_mnemonicqt_set_sequence_auto_mnemonic ( bool on ) ( bool on ) |
Enables automatic mnemonics on Mac if on is true; otherwise this feature is disabled. Note that this function is only available on Mac where mnemonics are disabled by default. To access to this function, use an extern declaration: extern void qt_set_sequence_auto_mnemonic(bool b); See also QShortcut. | ||
Look up this member in the source code. | ||
| Toggle details | int | qt_symbian_exception2Errorqt_symbian_exception2Error ( const std::exception &aThrow ...) ( const std::exception &aThrow ) |
Convert a caught standard C++ exception aThrow to a Symbian error code Warning: This function is only available on Symbian. See also qt_symbian_throwIfError() and qt_symbian_exception2LeaveL(). | ||
Look up this member in the source code. | ||
| Toggle details | void | qt_symbian_exception2LeaveLqt_symbian_exception2LeaveL ( const std::exception &aThrow ...) ( const std::exception &aThrow ) |
Convert a caught standard C++ exception aThrow to a Symbian leave Warning: This function is only available on Symbian. See also qt_symbian_throwIfError() and qt_symbian_exception2Error(). | ||
Look up this member in the source code. | ||
| Toggle details | void | qt_symbian_throwIfErrorqt_symbian_throwIfError ( int error ) ( int error ) |
Throws an exception if the error parameter is a symbian error code. This is the exception throwing equivalent of Symbian's User::LeaveIfError. Warning: This function is only available on Symbian. See also qt_symbian_exception2LeaveL() and qt_symbian_exception2Error(). | ||
Look up this member in the source code. | ||
Macros
| Toggle details | QT_POINTER_SIZEQT_POINTER_SIZE |
Expands to the size of a pointer in bytes (4 or 8). This is equivalent to sizeof(void *) but can be used in a preprocessor directive. | |
| Toggle details | QT_REQUIRE_VERSIONQT_REQUIRE_VERSION ( argc , argv , version ) |
This macro can be used to ensure that the application is run against a recent enough version of Qt. This is especially useful if your application depends on a specific bug fix introduced in a bug-fix release (e.g., 4.0.2). The argc and argv parameters are the main() function's argc and argv parameters. The version parameter is a string literal that specifies which version of Qt the application requires (e.g., "4.0.2"). Example:
| |
| Toggle details | QT_TRANSLATE_NOOP3QT_TRANSLATE_NOOP3 ( context , sourceText , comment ) |
Marks the string literal sourceText for dynamic translation in the given context and with comment, i.e the stored sourceText will not be altered. The context is typically a class and also needs to be specified as string literal. The string literal comment will be available for translators using e.g. Qt Linguist. The macro expands to anonymous struct of the two string literals passed as sourceText and comment. Example:
See also QT_TR_NOOP(), QT_TRANSLATE_NOOP(), and Internationalization with Qt. | |
| Toggle details | QT_TRANSLATE_NOOPQT_TRANSLATE_NOOP ( context , sourceText ) |
Marks the string literal sourceText for dynamic translation in the given context; i.e, the stored sourceText will not be altered. The context is typically a class and also needs to be specified as string literal. The macro expands to sourceText. Example:
See also QT_TR_NOOP(), QT_TRANSLATE_NOOP3(), and Internationalization with Qt. | |
| Toggle details | QT_TRAP_THROWINGQT_TRAP_THROWING ( function ) |
TRAP leaves from Symbian function and throws an appropriate standard C++ exception instead. This must be used when calling Symbian OS leaving functions from inside Qt or standard C++ code, so that the code can respond correctly to the exception. Warning: This macro is only available on Symbian. Example:
See also QT_TRYCATCH_ERROR() and QT_TRYCATCH_LEAVING(). | |
| Toggle details | QT_TRID_NOOPQT_TRID_NOOP ( id ) |
The QT_TRID_NOOP macro marks an id for dynamic translation. The only purpose of this macro is to provide an anchor for attaching meta data like to qtTrId(). The macro expands to id. Example:
See also qtTrId() and Internationalization with Qt. | |
| Toggle details | QT_TRYCATCH_ERRORQT_TRYCATCH_ERROR ( error , function ) |
Catch standard C++ exceptions from a function and convert them to a Symbian OS error code, or KErrNone if there is no exception. This must be used inside Qt or standard C++ code when using exception throwing code (practically anything) and returning an error code to Symbian OS. Warning: This macro is only available on Symbian. Example:
} See also QT_TRYCATCH_LEAVING() and QT_TRAP_THROWING(). | |
| Toggle details | QT_TRYCATCH_LEAVINGQT_TRYCATCH_LEAVING ( function ) |
Catch standard C++ exceptions from function and convert them to Symbian OS leaves. This must be used inside Qt or standard C++ code when using exception throwing code (practically anything) and returning to Symbian OS from a leaving function. For example inside a Symbian active object's RunL function implemented with Qt code. Warning: This macro is only available on Symbian. Example:
See also QT_TRAP_THROWING() and QT_TRYCATCH_ERROR(). | |
| Toggle details | QT_TR_NOOPQT_TR_NOOP ( sourceText ) |
Marks the string literal sourceText for dynamic translation in the current context (class), i.e the stored sourceText will not be altered. The macro expands to sourceText. Example:
The macro QT_TR_NOOP_UTF8() is identical except that it tells lupdate that the source string is encoded in UTF-8. Corresponding variants exist in the QT_TRANSLATE_NOOP() family of macros, too. Note that using these macros is not required if CODECFORTR is already set to UTF-8 in the qmake project file. See also QT_TRANSLATE_NOOP() and Internationalization with Qt. | |
| Toggle details | QT_VERSIONQT_VERSION |
This macro expands a numeric value of the form 0xMMNNPP (MM = major, NN = minor, PP = patch) that specifies Qt's version number. For example, if you compile your application against Qt 4.1.2, the QT_VERSION macro will expand to 0x040102. You can use QT_VERSION to use the latest Qt features where available. Example:
See also QT_VERSION_STR and qVersion(). | |
| Toggle details | QT_VERSION_CHECKQT_VERSION_CHECK |
Turns the major, minor and patch numbers of a version into an integer, 0xMMNNPP (MM = major, NN = minor, PP = patch). This can be compared with another similarly processed version id. See also QT_VERSION. | |
| Toggle details | QT_VERSION_STRQT_VERSION_STR |
This macro expands to a string that specifies Qt's version number (for example, "4.1.2"). This is the version against which the application is compiled. See also qVersion() and QT_VERSION. | |
| Toggle details | Q_ASSERTQ_ASSERT ( test ) |
Prints a warning message containing the source code file name and line number if test is false. Q_ASSERT() is useful for testing pre- and post-conditions during development. It does nothing if QT_NO_DEBUG was defined during compilation. Example:
If b is zero, the Q_ASSERT statement will output the following message using the qFatal() function:
See also Q_ASSERT_X(), qFatal(), and Debugging Techniques. | |
| Toggle details | Q_ASSERT_XQ_ASSERT_X ( test , where , what ) |
Prints the message what together with the location where, the source file name and line number if test is false. Q_ASSERT_X is useful for testing pre- and post-conditions during development. It does nothing if QT_NO_DEBUG was defined during compilation. Example:
If b is zero, the Q_ASSERT_X statement will output the following message using the qFatal() function:
See also Q_ASSERT(), qFatal(), and Debugging Techniques. | |
| Toggle details | Q_BIG_ENDIANQ_BIG_ENDIAN |
This macro represents a value you can compare to the macro Q_BYTE_ORDER to determine the endian-ness of your system. In a big-endian system, the most significant byte is stored at the lowest address. The other bytes follow in decreasing order of significance.
See also Q_BYTE_ORDER and Q_LITTLE_ENDIAN. | |
| Toggle details | Q_BYTE_ORDERQ_BYTE_ORDER |
This macro can be used to determine the byte order your system uses for storing data in memory. i.e., whether your system is little-endian or big-endian. It is set by Qt to one of the macros Q_LITTLE_ENDIAN or Q_BIG_ENDIAN. You normally won't need to worry about endian-ness, but you might, for example if you need to know which byte of an integer or UTF-16 character is stored in the lowest address. Endian-ness is important in networking, where computers with different values for Q_BYTE_ORDER must pass data back and forth. Use this macro as in the following examples.
See also Q_BIG_ENDIAN and Q_LITTLE_ENDIAN. | |
| Toggle details | Q_CC_BORQ_CC_BOR |
Defined if the application is compiled using Borland/Turbo C++. | |
| Toggle details | Q_CC_CDSQ_CC_CDS |
Defined if the application is compiled using Reliant C++. | |
| Toggle details | Q_CC_COMEAUQ_CC_COMEAU |
Defined if the application is compiled using Comeau C++. | |
| Toggle details | Q_CC_DECQ_CC_DEC |
Defined if the application is compiled using DEC C++. | |
| Toggle details | Q_CC_EDGQ_CC_EDG |
Defined if the application is compiled using Edison Design Group C++. | |
| Toggle details | Q_CC_GHSQ_CC_GHS |
Defined if the application is compiled using Green Hills Optimizing C++ Compilers. | |
| Toggle details | Q_CC_GNUQ_CC_GNU |
Defined if the application is compiled using GNU C++. | |
| Toggle details | Q_CC_HIGHCQ_CC_HIGHC |
Defined if the application is compiled using MetaWare High C/C++. | |
| Toggle details | Q_CC_HPACCQ_CC_HPACC |
Defined if the application is compiled using HP aC++. | |
| Toggle details | Q_CC_INTELQ_CC_INTEL |
Defined if the application is compiled using Intel C++ for Linux, Intel C++ for Windows. | |
| Toggle details | Q_CC_KAIQ_CC_KAI |
Defined if the application is compiled using KAI C++. | |
| Toggle details | Q_CC_MIPSQ_CC_MIPS |
Defined if the application is compiled using MIPSpro C++. | |
| Toggle details | Q_CC_MSVCQ_CC_MSVC |
Defined if the application is compiled using Microsoft Visual C/C++, Intel C++ for Windows. | |
| Toggle details | Q_CC_MWERKSQ_CC_MWERKS |
Defined if the application is compiled using Metrowerks CodeWarrior. | |
| Toggle details | Q_CC_OCQ_CC_OC |
Defined if the application is compiled using CenterLine C++. | |
| Toggle details | Q_CC_PGIQ_CC_PGI |
Defined if the application is compiled using Portland Group C++. | |
| Toggle details | Q_CC_SUNQ_CC_SUN |
Defined if the application is compiled using Forte Developer, or Sun Studio C++. | |
| Toggle details | Q_CC_SYMQ_CC_SYM |
Defined if the application is compiled using Digital Mars C/C++ (used to be Symantec C++). | |
| Toggle details | Q_CC_USLCQ_CC_USLC |
Defined if the application is compiled using SCO OUDK and UDK. | |
| Toggle details | Q_CC_WATQ_CC_WAT |
Defined if the application is compiled using Watcom C++. | |
| Toggle details | Q_CHECK_PTRQ_CHECK_PTR ( pointer ) |
If pointer is 0, prints a warning message containing the source code's file name and line number, saying that the program ran out of memory. Q_CHECK_PTR does nothing if QT_NO_DEBUG was defined during compilation. Example:
See also qWarning() and Debugging Techniques. | |
| Toggle details | Q_DECLARE_TYPEINFOQ_DECLARE_TYPEINFO ( Type , Flags ) |
You can use this macro to specify information about a custom type Type. With accurate type information, Qt's generic containers can choose appropriate storage methods and algorithms. Flags can be one of the following:
Example of a "primitive" type:
Example of a movable type:
| |
| Toggle details | Q_DECL_EXPORTQ_DECL_EXPORT |
This macro marks a symbol for shared library export (see Creating Shared Libraries). See also Q_DECL_IMPORT. | |
| Toggle details | Q_DECL_IMPORTQ_DECL_IMPORT |
This macro declares a symbol to be an import from a shared library (see Creating Shared Libraries). See also Q_DECL_EXPORT. | |
| Toggle details | Q_FOREACHQ_FOREACH ( variable , container ) |
Same as foreach(variable, container). This macro is available even when no_keywords is specified using the .pro file's CONFIG variable. See also foreach(). | |
| Toggle details | Q_FOREVERQ_FOREVER |
| Toggle details | Q_FUNC_INFOQ_FUNC_INFO |
Expands to a string that describe the function the macro resides in. How this string looks more specifically is compiler dependent. With GNU GCC it is typically the function signature, while with other compilers it might be the line and column number. Q_FUNC_INFO can be conveniently used with qDebug(). For example, this function:
when instantiated with the integer type, will with the GCC compiler produce: const TInputType& myMin(const TInputType&, const TInputType&) [with TInputType = int] was called with value1: 3 value2: 4 If this macro is used outside a function, the behavior is undefined. | |
| Toggle details | Q_INT64_CQ_INT64_C ( literal ) |
Wraps the signed 64-bit integer literal in a platform-independent way. Example:
See also qint64 and Q_UINT64_C(). | |
| Toggle details | Q_LITTLE_ENDIANQ_LITTLE_ENDIAN |
This macro represents a value you can compare to the macro Q_BYTE_ORDER to determine the endian-ness of your system. In a little-endian system, the least significant byte is stored at the lowest address. The other bytes follow in increasing order of significance.
See also Q_BYTE_ORDER and Q_BIG_ENDIAN. | |
| Toggle details | Q_OS_AIXQ_OS_AIX |
Defined on AIX. | |
| Toggle details | Q_OS_BSD4Q_OS_BSD4 |
Defined on Any BSD 4.4 system. | |
| Toggle details | Q_OS_BSDIQ_OS_BSDI |
Defined on BSD/OS. | |
| Toggle details | Q_OS_CYGWINQ_OS_CYGWIN |
Defined on Cygwin. | |
| Toggle details | Q_OS_DARWINQ_OS_DARWIN |
Defined on Darwin OS (synonym for Q_OS_MAC). | |
| Toggle details | Q_OS_DGUXQ_OS_DGUX |
Defined on DG/UX. | |
| Toggle details | Q_OS_DYNIXQ_OS_DYNIX |
Defined on DYNIX/ptx. | |
| Toggle details | Q_OS_FREEBSDQ_OS_FREEBSD |
Defined on FreeBSD. | |
| Toggle details | Q_OS_HPUXQ_OS_HPUX |
Defined on HP-UX. | |
| Toggle details | Q_OS_HURDQ_OS_HURD |
Defined on GNU Hurd. | |
| Toggle details | Q_OS_IRIXQ_OS_IRIX |
Defined on SGI Irix. | |
| Toggle details | Q_OS_LINUXQ_OS_LINUX |
Defined on Linux. | |
| Toggle details | Q_OS_LYNXQ_OS_LYNX |
Defined on LynxOS. | |
| Toggle details | Q_OS_MACQ_OS_MAC |
Defined on MAC OS (synonym for Darwin). | |
| Toggle details | Q_OS_MSDOSQ_OS_MSDOS |
Defined on MS-DOS and Windows. | |
| Toggle details | Q_OS_NETBSDQ_OS_NETBSD |
Defined on NetBSD. | |
| Toggle details | Q_OS_OS2Q_OS_OS2 |
Defined on OS/2. | |
| Toggle details | Q_OS_OPENBSDQ_OS_OPENBSD |
Defined on OpenBSD. | |
| Toggle details | Q_OS_OS2EMXQ_OS_OS2EMX |
Defined on XFree86 on OS/2 (not PM). | |
| Toggle details | Q_OS_OSFQ_OS_OSF |
Defined on HP Tru64 UNIX. | |
| Toggle details | Q_OS_QNXQ_OS_QNX |
Defined on QNX Neutrino. | |
| Toggle details | Q_OS_RELIANTQ_OS_RELIANT |
Defined on Reliant UNIX. | |
| Toggle details | Q_OS_SCOQ_OS_SCO |
Defined on SCO OpenServer 5. | |
| Toggle details | Q_OS_SOLARISQ_OS_SOLARIS |
Defined on Sun Solaris. | |
| Toggle details | Q_OS_SYMBIANQ_OS_SYMBIAN |
Defined on Symbian. | |
| Toggle details | Q_OS_ULTRIXQ_OS_ULTRIX |
Defined on DEC Ultrix. | |
| Toggle details | Q_OS_UNIXQ_OS_UNIX |
Defined on Any UNIX BSD/SYSV system. | |
| Toggle details | Q_OS_UNIXWAREQ_OS_UNIXWARE |
Defined on UnixWare 7, Open UNIX 8. | |
| Toggle details | Q_OS_WIN32Q_OS_WIN32 |
Defined on all supported versions of Windows. | |
| Toggle details | Q_OS_WINCEQ_OS_WINCE |
Defined on Windows CE. | |
| Toggle details | Q_UINT64_CQ_UINT64_C ( literal ) |
| Toggle details | Q_UNUSEDQ_UNUSED ( name ) |
Indicates to the compiler that the parameter with the specified name is not used in the body of a function. This can be used to suppress compiler warnings while allowing functions to be defined with meaningful parameter names in their signatures. | |
| Toggle details | Q_WS_S60Q_WS_S60 |
| Toggle details | Q_WS_X11Q_WS_X11 |
| Toggle details | Q_WS_MACQ_WS_MAC |
| Toggle details | Q_WS_QWSQ_WS_QWS |
| Toggle details | Q_WS_WINQ_WS_WIN |
| Toggle details | foreachforeach ( variable , container ) |
This macro is used to implement Qt's foreach loop. The variable parameter is a variable name or variable definition; the container parameter is a Qt container whose value type corresponds to the type of the variable. See The foreach Keyword for details. If you're worried about namespace pollution, you can disable this macro by adding the following line to your .pro file:
See also Q_FOREACH(). | |
| Toggle details | foreverforever |
This macro is provided for convenience for writing infinite loops. Example:
It is equivalent to for (;;). If you're worried about namespace pollution, you can disable this macro by adding the following line to your .pro file:
See also Q_FOREVER. | |
| Toggle details | qPrintableqPrintable ( str ) |
Returns str as a const char *. This is equivalent to str.toLocal8Bit().constData(). The char pointer will be invalid after the statement in which qPrintable() is used. This is because the array returned by toLocal8Bit() will fall out of scope. Example:
| |
| Toggle details | FALSEFALSE![]() |
Synonym for false. See also TRUE. | |
| Toggle details | QABSQABS (
n
)![]() |
| Toggle details | QMAXQMAX (
x
,
y
)![]() |
| Toggle details | QMINQMIN (
x
,
y
)![]() |
| Toggle details | TRUETRUE![]() |
Synonym for true. See also FALSE. | |



Votes: 3
Coverage: Qt library 4.7, 4.8, 5.0
Mad Scientist
2 notes
environment variables
If you need a list of all environment variables:
Check QProcess::systemEnvironment() [developer.qt.nokia.com]
[Revisions]