?? qglobal.cpp
字號(hào):
qCritical("File '%s' does not exist!", qPrintable(fileName)); } \endcode \warning The internal buffer is limited to 8192 bytes, including the '\0'-terminator. \warning Passing (const char *)0 as argument to qCritical might lead to crashes on certain platforms due to the platforms printf implementation. \sa qDebug(), qWarning(), qFatal(), qInstallMsgHandler(), {Debugging Techniques}*/void qCritical(const char *msg, ...){ char buf[QT_BUFFER_LENGTH]; buf[QT_BUFFER_LENGTH - 1] = '\0'; va_list ap; va_start(ap, msg); // use variable arg list qvsnprintf(buf, QT_BUFFER_LENGTH - 1, msg, ap); va_end(ap); qt_message_output(QtCriticalMsg, buf);}#ifdef QT3_SUPPORTvoid qSystemWarning(const char *msg, int code) { qCritical("%s (%s)", msg, qt_error_string(code).toLocal8Bit().constData()); }#endif // QT3_SUPPORTvoid qErrnoWarning(const char *msg, ...){ char buf[QT_BUFFER_LENGTH]; buf[QT_BUFFER_LENGTH - 1] = '\0'; va_list ap; va_start(ap, msg); qvsnprintf(buf, QT_BUFFER_LENGTH - 1, msg, ap); va_end(ap); qCritical("%s (%s)", buf, qt_error_string(-1).toLocal8Bit().constData());}void qErrnoWarning(int code, const char *msg, ...){ char buf[QT_BUFFER_LENGTH]; buf[QT_BUFFER_LENGTH - 1] = '\0'; va_list ap; va_start(ap, msg); qvsnprintf(buf, QT_BUFFER_LENGTH - 1, msg, ap); va_end(ap); qCritical("%s (%s)", buf, qt_error_string(code).toLocal8Bit().constData());}/*! \relates <QtGlobal> Calls the message handler with the fatal message \a msg. If no message handler has been installed, the message is printed to stderr. Under Windows, the message is sent to the debugger. For a release library this function will exit the application with return value 1. For the debug version this function will abort on Unix systems to create a core dump, and report a _CRT_ERROR on Windows allowing 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: \code int divide(int a, int b) { if (b == 0) // program error qFatal("divide: cannot divide by zero"); return a / b; } \endcode \warning The internal buffer is limited to 8192 bytes, including the '\0'-terminator. \warning Passing (const char *)0 as argument to qFatal might lead to crashes on certain platforms due to the platforms printf implementation. \sa qDebug(), qCritical(), qWarning(), qInstallMsgHandler(), {Debugging Techniques}*/void qFatal(const char *msg, ...){ char buf[QT_BUFFER_LENGTH]; buf[QT_BUFFER_LENGTH - 1] = '\0'; va_list ap; va_start(ap, msg); // use variable arg list qvsnprintf(buf, QT_BUFFER_LENGTH - 1, msg, ap); va_end(ap); qt_message_output(QtFatalMsg, buf);}// getenv is declared as deprecated in VS2005. This function// makes use of the new secure getenv function.QByteArray qgetenv(const char *varName){#if defined(_MSC_VER) && _MSC_VER >= 1400 size_t requiredSize; QByteArray buffer; getenv_s(&requiredSize, 0, 0, varName); if (requiredSize == 0) return buffer; buffer.resize(int(requiredSize)); getenv_s(&requiredSize, buffer.data(), requiredSize, varName); return buffer;#else return QByteArray(::getenv(varName));#endif}#if defined(Q_OS_UNIX) && !defined(QT_NO_THREAD)static QThreadStorage<uint *> randTLS; // Thread Local Storage for seed value#endif/*! \since 4.2 Thread-safe version of the standard C++ \c srand() function. Sets the argument \a seed to be used to generate a new random number sequence of pseudo random integers to be returned by qrand(). If no seed value is provided, qrand() is automatically seeded with a value of 1. 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. \sa qrand()*/void qsrand(uint seed){#if defined(Q_OS_UNIX) && !defined(QT_NO_THREAD) if (!randTLS.hasLocalData()) randTLS.setLocalData(new uint); *randTLS.localData() = seed;#else // On Windows srand() and rand() already use Thread-Local-Storage // to store the seed between calls srand(seed);#endif}/*! \since 4.2 Thread-safe version of the standard C++ \c rand() function. Returns a value between 0 and \c RAND_MAX (defined in \c <cstdlib> and \c <stdlib.h>), the next number in the current sequence of pseudo-random integers. Use \c qsrand() to initialize the pseudo-random number generator with a seed value. \sa qsrand()*/int qrand(){#if defined(Q_OS_UNIX) && !defined(QT_NO_THREAD) if (!randTLS.hasLocalData()) { randTLS.setLocalData(new uint); *randTLS.localData() = 1; } return rand_r(randTLS.localData());#else // On Windows srand() and rand() already use Thread-Local-Storage // to store the seed between calls return rand();#endif}/*! \macro forever \relates <QtGlobal> This macro is provided for convenience for writing infinite loops. Example: \code forever { ... } \endcode It is equivalent to \c{for (;;)}. If you're worried about namespace pollution, you can disable this macro by adding the following line to your \c .pro file: \code CONFIG += no_keywords \endcode \sa Q_FOREVER*//*! \macro Q_FOREVER \relates <QtGlobal> Same as \l{forever}. This macro is available even when \c no_keywords is specified using the \c .pro file's \c CONFIG variable. \sa foreach()*//*! \macro foreach(variable, container) \relates <QtGlobal> This macro is used to implement Qt's \c foreach loop. The \a variable parameter is a variable name or variable definition; the \a container parameter is a Qt container whose value type corresponds to the type of the variable. See \l{The foreach Keyword} for details. If you're worried about namespace pollution, you can disable this macro by adding the following line to your \c .pro file: \code CONFIG += no_keywords \endcode \sa Q_FOREACH()*//*! \macro Q_FOREACH(variable, container) \relates <QtGlobal> Same as foreach(\a variable, \a container). This macro is available even when \c no_keywords is specified using the \c .pro file's \c CONFIG variable. \sa foreach()*//*! \macro const char *QT_TR_NOOP(const char *sourceText) \relates <QtGlobal> Marks the string literal \a sourceText for dynamic translation in the current context (class), i.e the stored \a sourceText will not be altered. For example: \code QString FriendlyConversation::greeting(int type) { static const char *greeting_strings[] = { QT_TR_NOOP("Hello"), QT_TR_NOOP("Goodbye") }; return tr(greeting_strings[type]); } \endcode The macro expands to \a sourceText. \sa QT_TRANSLATE_NOOP(), {Internationalization with Qt}*//*! \macro const char *QT_TRANSLATE_NOOP(const char *context, const char *sourceText) \relates <QtGlobal> Marks the string literal \a sourceText for dynamic translation in the given \a context, i.e the stored \a sourceText will not be altered. The \a context is typically a class. For example: \code 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]); } \endcode The macro expands to \a sourceText. \sa QT_TR_NOOP(), {Internationalization with Qt}*//*! \macro QT_POINTER_SIZE \relates <QtGlobal> Expands to the size of a pointer in bytes (4 or 8). This is equivalent to \c sizeof(void *) but can be used in a preprocessor directive.*//*! \macro TRUE \relates <QtGlobal> \obsolete Synonym for \c true. \sa FALSE*//*! \macro FALSE \relates <QtGlobal> \obsolete Synonym for \c false. \sa TRUE*//*! \macro QABS(n) \relates <QtGlobal> \obsolete Use qAbs(\a n) instead. \sa QMIN(), QMAX()*//*! \macro QMIN(x, y) \relates <QtGlobal> \obsolete Use qMin(\a x, \a y) instead. \sa QMAX(), QABS()*//*! \macro QMAX(x, y) \relates <QtGlobal> \obsolete Use qMax(\a x, \a y) instead. \sa QMIN(), QABS()*//*! \macro const char *qPrintable(const QString &str) \relates <QtGlobal> Returns \a str as a \c{const char *}. This is equivalent to \a{str}.toLocal8bit().constData(). Example: \code qWarning("%s: %s", qPrintable(key), qPrintable(value)); \endcode \sa qDebug(), qWarning(), qCritical(), qFatal()*//*! \macro Q_DECLARE_TYPEINFO(Type, Flags) \relates <QtGlobal> You can use this macro to specify information about a custom type \a Type. With accurate type information, Qt's \l{generic containers} can choose appropriate storage methods and algorithms. \a Flags can be one of the following: \list \o \c Q_PRIMITIVE_TYPE specifies that \a Type is a POD (plain old data) type with no constructor or destructor. \o \c Q_MOVABLE_TYPE specifies that \a Type has a constructor and/or a destructor but can be moved in memory using \c memcpy(). \o \c Q_COMPLEX_TYPE (the default) specifies that \a Type has constructors and/or a destructor and that it may not be moved in memory. \endlist Example of a "primitive" type: \code struct Point2D { int x; int y; }; Q_DECLARE_TYPEINFO(Point2D, Q_PRIMITIVE_TYPE); \endcode Example of a movable type: \code class Point2D { public: Point2D() { data = new int[2]; } Point2D(const Point2D &other) { ... } ~Point2D() { delete[] data; } Point2D &operator=(const Point2D &other) { ... } int x() const { return data[0]; } int y() const { return data[1]; } private: int *data; }; Q_DECLARE_TYPEINFO(Point2D, Q_MOVABLE_TYPE); \endcode*//*! \macro Q_UNUSED(name) \relates <QtGlobal> Indicates to the compiler that the parameter with the specified \a 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.*/#if defined(QT3_SUPPORT) && !defined(QT_NO_SETTINGS)#include <qlibraryinfo.h>static const char *qInstallLocation(QLibraryInfo::LibraryLocation loc){ static QByteArray ret; ret = QLibraryInfo::location(loc).toLatin1(); return ret.constData();}const char *qInstallPath(){ return qInstallLocation(QLibraryInfo::PrefixPath);}const char *qInstallPathDocs(){ return qInstallLocation(QLibraryInfo::DocumentationPath);}const char *qInstallPathHeaders(){ return qInstallLocation(QLibraryInfo::HeadersPath);}const char *qInstallPathLibs(){ return qInstallLocation(QLibraryInfo::LibrariesPath);}const char *qInstallPathBins(){ return qInstallLocation(QLibraryInfo::BinariesPath);}const char *qInstallPathPlugins(){ return qInstallLocation(QLibraryInfo::PluginsPath);}const char *qInstallPathData(){ return qInstallLocation(QLibraryInfo::DataPath);}const char *qInstallPathTranslations(){ return qInstallLocation(QLibraryInfo::TranslationsPath);}const char *qInstallPathSysconf(){ return qInstallLocation(QLibraryInfo::SettingsPath);}#endifstruct QInternal_CallBackTable { QVector<QList<qInternalCallback> > callbacks;};Q_GLOBAL_STATIC(QInternal_CallBackTable, global_callback_table);bool QInternal::registerCallback(Callback cb, qInternalCallback callback){ if (cb >= 0 && cb < QInternal::LastCallback) { QInternal_CallBackTable *cbt = global_callback_table(); cbt->callbacks.resize(cb + 1); cbt->callbacks[cb].append(callback); return true; } return false;}bool QInternal::unregisterCallback(Callback cb, qInternalCallback callback){ if (cb >= 0 && cb < QInternal::LastCallback) { QInternal_CallBackTable *cbt = global_callback_table(); return (bool) cbt->callbacks[cb].removeAll(callback); } return false;}bool QInternal::activateCallbacks(Callback cb, void **parameters){ Q_ASSERT_X(cb >= 0, "QInternal::activateCallback()", "Callback id must be a valid id"); QInternal_CallBackTable *cbt = global_callback_table(); if (cbt && cb < cbt->callbacks.size()) { QList<qInternalCallback> callbacks = cbt->callbacks[cb]; bool ret = false; for (int i=0; i<callbacks.size(); ++i) ret |= (callbacks.at(i))(p
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -