![]() | Home · All Classes · Modules |
The QtCore module contains core non-GUI functionality. More...
The QtCore module contains non-GUI functionality.
All other PyQt modules rely on this module. To import the module use, for example, the following statement:
from PyQt4 import QtCore
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.
Constant | Value | Description |
---|---|---|
QtDebugMsg | 0 | A message generated by the qDebug() function. |
QtWarningMsg | 1 | A message generated by the qWarning() function. |
QtCriticalMsg | 2 | A message generated by the qCritical() function. |
QtFatalMsg | 3 | A message generated by the qFatal() function. |
QtSystemMsg | QtCriticalMsg |
See also QtMsgHandler and qInstallMsgHandler().
Calls QTextStream.setIntegerBase(2) on stream and returns stream.
See also oct(), dec(), hex(), and QTextStream manipulators.
Calls QTextStream.setIntegerBase(2) on stream and returns stream.
See also oct(), dec(), hex(), and QTextStream manipulators.
Toggles insertion of the Byte Order Mark on stream when QTextStream is used with a UTF codec.
See also QTextStream.setGenerateByteOrderMark() and QTextStream manipulators.
Calls QTextStream.setFieldAlignment(QTextStream.AlignCenter) on stream and returns stream.
See also left(), right(), and QTextStream manipulators.
Calls QTextStream.setIntegerBase(10) on stream and returns stream.
See also bin(), oct(), hex(), and QTextStream manipulators.
Writes '\n' to the stream and flushes the stream.
Equivalent to
stream << '\n' << flush;
Note: On Windows, all '\n' characters are written as '\r\n' if QTextStream's device or string is opened using the QIODevice.Text flag.
See also flush(), reset(), and QTextStream manipulators.
Calls QTextStream.setRealNumberNotation(QTextStream.FixedNotation) on stream and returns stream.
See also scientific() and QTextStream manipulators.
Flushes any buffered data waiting to be written to the device.
If QTextStream operates on a string, this function does nothing.
Calls QTextStream.setNumberFlags(QTextStream.numberFlags() | QTextStream.ForcePoint) on stream and returns stream.
See also noforcepoint(), forcesign(), showbase(), and QTextStream manipulators.
Calls QTextStream.setNumberFlags(QTextStream.numberFlags() | QTextStream.ForceSign) on stream and returns stream.
See also noforcesign(), forcepoint(), showbase(), and QTextStream manipulators.
Calls QTextStream.setIntegerBase(16) on stream and returns stream.
Note: The hex modifier can only be used for writing to streams.
See also bin(), oct(), dec(), and QTextStream manipulators.
Calls QTextStream.setIntegerBase(16) on stream and returns stream.
Note: The hex modifier can only be used for writing to streams.
See also bin(), oct(), dec(), and QTextStream manipulators.
Calls QTextStream.setFieldAlignment(QTextStream.AlignLeft) on stream and returns stream.
See also right(), center(), and QTextStream manipulators.
Calls QTextStream.setNumberFlags(QTextStream.numberFlags() & ~QTextStream.UppercaseBase) on stream and returns stream.
See also uppercasebase(), lowercasedigits(), and QTextStream manipulators.
Calls QTextStream.setNumberFlags(QTextStream.numberFlags() & ~QTextStream.UppercaseDigits) on stream and returns stream.
See also uppercasedigits(), lowercasebase(), and QTextStream manipulators.
Calls QTextStream.setNumberFlags(QTextStream.numberFlags() & ~QTextStream.ForcePoint) on stream and returns stream.
See also forcepoint(), noforcesign(), noshowbase(), and QTextStream manipulators.
Calls QTextStream.setNumberFlags(QTextStream.numberFlags() & ~QTextStream.ForceSign) on stream and returns stream.
See also forcesign(), noforcepoint(), noshowbase(), and QTextStream manipulators.
Calls QTextStream.setNumberFlags(QTextStream.numberFlags() & ~QTextStream.ShowBase) on stream and returns stream.
See also showbase(), noforcesign(), noforcepoint(), and QTextStream manipulators.
Calls QTextStream.setIntegerBase(8) on stream and returns stream.
See also bin(), dec(), hex(), and QTextStream manipulators.
Calls QTextStream.setIntegerBase(8) on stream and returns stream.
See also bin(), dec(), hex(), and QTextStream manipulators.
When the QtCore module is imported for the first time it installs a Python input hook (ie. it sets the value of Python's PyOS_InputHook variable). This allows commands to be entered at the interpreter prompt while the application is running. It is then possible to dynamically create new Qt objects and call the methods of any existing Qt object.
The input hook can cause problems for certain types of application, particularly those that provide a similar facility through different means. This function removes the input hook installed by PyQt.
The input hook can be restored using the pyqtRestoreInputHook() function.
When the QtCore module is imported for the first time it installs a Python input hook (ie. it sets the value of Python's PyOS_InputHook variable). This allows commands to be entered at the interpreter prompt while the application is running. It is then possible to dynamically create new Qt objects and call the methods of any existing Qt object.
The input hook can cause problems for certain types of application, particularly those that provide a similar facility through different means, and so the pyqtRemoveInputHook() function is provided to remove it.
This function will restore the input hook if it has been removed.
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:
int absoluteValue;
int myValue = -4;
absoluteValue = qAbs(myValue);
// absoluteValue == 4
Returns the CRC-16 checksum of the first len bytes of data.
The checksum is independent of the byte order (endianness).
Note: This function is a 16-bit cache conserving (16 entry table) implementation of the CRC-16-CCITT algorithm.
Compresses the data byte array and returns the compressed data in a new byte array.
The compressionLevel parameter specifies how much compression should be used. Valid values are between 0 and 9, with 9 corresponding to the greatest compression (i.e. smaller compressed data) at the cost of using a slower algorithm. Smaller values (8, 7, ..., 1) provide successively less compression at slightly faster speeds. The value 0 corresponds to no compression at all. The default value is -1, which specifies zlib's default compression.
See also qUncompress().
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:
void load(const QString &fileName) { QFile file(fileName); if (!file.exists()) qCritical("File '%s' does not exist!", qPrintable(fileName)); }
If you include <QtDebug>, a more convenient syntax is also available:
qCritical() << "Brush:" << myQBrush << "Other value:" << i;
A space is inserted between the items, and a newline is appended at the end.
To supress the output at runtime, install your own message handler with qInstallMsgHandler().
See also qDebug(), qWarning(), qFatal(), qInstallMsgHandler(), and Debugging Techniques.
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:
qDebug("Items in list: %d", myList.size());
If you include <QtDebug>, a more convenient syntax is also available:
qDebug() << "Brush:" << myQBrush << "Other value:" << i;
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.
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:
int divide(int a, int b)
{
if (b == 0) // program error
qFatal("divide: cannot divide by zero");
return a / b;
}
To supress the output at runtime, install your own message handler with qInstallMsgHandler().
See also qDebug(), qCritical(), qWarning(), qInstallMsgHandler(), and Debugging Techniques.
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.
// Instead of comparing with 0.0 qFuzzyCompare(0.0,1.0e-200); // This will return false // Compare adding 1 to both values will fix the problem qFuzzyCompare(1 + 0.0, 1 + 1.0e-200); // This will return true
The two numbers are compared in a relative way, where the exactness is stronger the smaller the numbers are.
Note: This function is thread-safe.
This function was introduced in Qt 4.4.
The callable argument may also be None.
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:
#include <qapplication.h> #include <stdio.h> #include <stdlib.h> void myMessageOutput(QtMsgType type, const char *msg) { switch (type) { case QtDebugMsg: fprintf(stderr, "Debug: %s\n", msg); break; case QtWarningMsg: fprintf(stderr, "Warning: %s\n", msg); break; case QtCriticalMsg: fprintf(stderr, "Critical: %s\n", msg); break; case QtFatalMsg: fprintf(stderr, "Fatal: %s\n", msg); abort(); } } int main(int argc, char **argv) { qInstallMsgHandler(myMessageOutput); QApplication app(argc, argv); ... return app.exec(); }
See also qDebug(), qWarning(), qCritical(), qFatal(), QtMsgType, and Debugging Techniques.
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.
This function was introduced in Qt 4.2.
See also qsrand().
Rounds value to the nearest integer.
Example:
qreal valueA = 2.3; qreal valueB = 2.7; int roundedValueA = qRound(valueA); // roundedValueA = 2 int roundedValueB = qRound(valueB); // roundedValueB = 3
Rounds value to the nearest 64-bit integer.
Example:
qreal valueA = 42949672960.3; qreal valueB = 42949672960.7; int roundedValueA = qRound(valueA); // roundedValueA = 42949672960 int roundedValueB = qRound(valueB); // roundedValueB = 42949672961
Equivalent to QTextStream.setFieldWidth(width).
Equivalent to QTextStream.setPadChar(ch).
Equivalent to QTextStream.setRealNumberPrecision(precision).
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.
This function was introduced in Qt 4.2.
See also qrand().
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:
QString FriendlyConversation.greeting(int type) { static const char *greeting_strings[] = { QT_TR_NOOP("Hello"), QT_TR_NOOP("Goodbye") }; return tr(greeting_strings[type]); }
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.
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:
static const char *greeting_strings[] = { QT_TRANSLATE_NOOP("FriendlyConversation", "Hello"), QT_TRANSLATE_NOOP("FriendlyConversation", "Goodbye") }; QString FriendlyConversation.greeting(int type) { return tr(greeting_strings[type]); } QString global_greeting(int type) { return qApp->translate("FriendlyConversation", greeting_strings[type]); }
See also QT_TR_NOOP(), QT_TRANSLATE_NOOP3(), and Internationalization with Qt.
Uncompresses the data byte array and returns a new byte array with the uncompressed data.
Returns an empty QByteArray if the input data was corrupt.
This function will uncompress data compressed with qCompress() from this and any earlier Qt version, back to Qt 3.1 when this feature was added.
Note: If you want to use this function to uncompress external data compressed using zlib, you first need to prepend four bytes to the byte array that contain the expected length (as an unsigned integer) of the uncompressed data encoded in big-endian order (most significant byte first).
See also qCompress().
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.
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:
void f(int c) { if (c > 200) qWarning("f: bad argument, c == %d", c); }
If you include <QtDebug>, a more convenient syntax is also available:
qWarning() << "Brush:" << myQBrush << "Other value:" << i;
This syntax inserts a space between each item, and appends a newline at the end.
To supress the output at runtime, install your own message handler with qInstallMsgHandler().
See also qDebug(), qCritical(), qFatal(), qInstallMsgHandler(), and Debugging Techniques.
Resets QTextStream's formatting options, bringing it back to its original constructed state. The device, string and any buffered data is left untouched.
Calls QTextStream.setFieldAlignment(QTextStream.AlignRight) on stream and returns stream.
See also left(), center(), and QTextStream manipulators.
Calls QTextStream.setRealNumberNotation(QTextStream.ScientificNotation) on stream and returns stream.
See also fixed() and QTextStream manipulators.
Calls QTextStream.setNumberFlags(QTextStream.numberFlags() | QTextStream.ShowBase) on stream and returns stream.
See also noshowbase(), forcesign(), forcepoint(), and QTextStream manipulators.
Calls QTextStream.setNumberFlags(QTextStream.numberFlags() | QTextStream.UppercaseBase) on stream and returns stream.
See also lowercasebase(), uppercasedigits(), and QTextStream manipulators.
Calls QTextStream.setNumberFlags(QTextStream.numberFlags() | QTextStream.UppercaseDigits) on stream and returns stream.
See also lowercasedigits(), uppercasebase(), and QTextStream manipulators.
Calls skipWhiteSpace() on stream and returns stream.
See also QTextStream manipulators.
This member should be treated as a constant.
This member should be treated as a constant.
This member should be treated as a constant.
This member should be treated as a constant.
PyQt 4.7.3 for X11 | Copyright © Riverbank Computing Ltd and Nokia 2010 | Qt 4.6.2 |