Additional Functions

qApp()

Qore wrapper for qApp Qt4 pointer, a global and unique application object. It is equivalent to the object returned by the QCoreApplication::instance() function except that, in GUI applications, it is a QApplication instance. Only one application object can be created.

qDebug(arg1, arg2, …, argN)

It's used for writing custom debug output. output of given arguments to stderr. It's a wrapper around extended qDebug() class from C++. Calls like:

Example 2.6. qDebug differences between C++ and Qore

 C++: qDebug() << “string” << myObj;
Qore: qDebug(“string”, $myObj);

qWarning(arg1, arg2, …, argN)

It's used to report warnings and recoverable errors in your application. Usage is the same as in qDebug() described above.

qCritical(arg1, arg2, …, argN)

It's used for writing critical error mesages and reporting system errors. Usage is the same as for qDebug().

qFatal(arg1, arg2, …, argN)

It's used for writing fatal error messages shortly before exiting. This function will exit the application too. Usage is the same as for qDebug().

qRound(number)

It takes any number (bigint, float…) and rounds it. It returns 0 for unsupported variable types (strings, etc).

qsrand(number)

It initializes random number generator qrand() with seed as argument.

Example 2.7. Typical qsrand usage

qsrand( now_ms() );

qrand()

It returns a random number. See qsrand().

qSwap(ref1, ref2)

It takes two references and swap their values.

Example 2.8. qSwap usage

my $ref1 = 10;
my $ref2 = "foo";
qSwap(\$ref1, \$ref2);
printf("ref1: %N ; ref2: %N\n", $ref1, $ref2);
              

qVersion()

It prints Qt version as string in “4.5.2” format. See QT_VERSION and QT_VERSION_STR Qore constants.