📄 qglobal.h
字号:
to work.*/#if defined Q_CC_MSVC && _MSC_VER < 1300template <typename T>inline void qSwap_helper(T &value1, T &value2, T*){ T t = value1; value1 = value2; value2 = t;}#define Q_DECLARE_SHARED(TYPE) \template <> inline bool qIsDetached<TYPE>(TYPE &t) { return t.isDetached(); } \template <> inline void qSwap_helper<TYPE>(TYPE &value1, TYPE &value2, TYPE*) \{ \ const TYPE::DataPtr t = value1.data_ptr(); \ value1.data_ptr() = value2.data_ptr(); \ value2.data_ptr() = t; \}#else#define Q_DECLARE_SHARED(TYPE) \template <> inline bool qIsDetached<TYPE>(TYPE &t) { return t.isDetached(); } \template <typename T> inline void qSwap(T &, T &); \template <> inline void qSwap<TYPE>(TYPE &value1, TYPE &value2) \{ \ const TYPE::DataPtr t = value1.data_ptr(); \ value1.data_ptr() = value2.data_ptr(); \ value2.data_ptr() = t; \}#endif/* QTypeInfo primitive specializations*/Q_DECLARE_TYPEINFO(bool, Q_PRIMITIVE_TYPE);Q_DECLARE_TYPEINFO(char, Q_PRIMITIVE_TYPE);Q_DECLARE_TYPEINFO(signed char, Q_PRIMITIVE_TYPE);Q_DECLARE_TYPEINFO(uchar, Q_PRIMITIVE_TYPE);Q_DECLARE_TYPEINFO(short, Q_PRIMITIVE_TYPE);Q_DECLARE_TYPEINFO(ushort, Q_PRIMITIVE_TYPE);Q_DECLARE_TYPEINFO(int, Q_PRIMITIVE_TYPE);Q_DECLARE_TYPEINFO(uint, Q_PRIMITIVE_TYPE);Q_DECLARE_TYPEINFO(long, Q_PRIMITIVE_TYPE);Q_DECLARE_TYPEINFO(ulong, Q_PRIMITIVE_TYPE);Q_DECLARE_TYPEINFO(qint64, Q_PRIMITIVE_TYPE);Q_DECLARE_TYPEINFO(quint64, Q_PRIMITIVE_TYPE);Q_DECLARE_TYPEINFO(float, Q_PRIMITIVE_TYPE);Q_DECLARE_TYPEINFO(double, Q_PRIMITIVE_TYPE);#ifndef Q_OS_DARWINQ_DECLARE_TYPEINFO(long double, Q_PRIMITIVE_TYPE);#endif/* These functions make it possible to use standard C++ functions with a similar name from Qt header files (especially template classes).*/Q_CORE_EXPORT void *qMalloc(size_t size);Q_CORE_EXPORT void qFree(void *ptr);Q_CORE_EXPORT void *qRealloc(void *ptr, size_t size);Q_CORE_EXPORT void *qMemCopy(void *dest, const void *src, size_t n);Q_CORE_EXPORT void *qMemSet(void *dest, int c, size_t n);/* Avoid some particularly useless warnings from some stupid compilers. To get ALL C++ compiler warnings, define QT_CC_WARNINGS or comment out the line "#define QT_NO_WARNINGS".*/#if !defined(QT_CC_WARNINGS)# define QT_NO_WARNINGS#endif#if defined(QT_NO_WARNINGS)# if defined(Q_CC_MSVC)# pragma warning(disable: 4251) /* class 'A' needs to have dll interface for to be used by clients of class 'B'. */# pragma warning(disable: 4244) /* 'conversion' conversion from 'type1' to 'type2', possible loss of data */# pragma warning(disable: 4275) /* non - DLL-interface classkey 'identifier' used as base for DLL-interface classkey 'identifier' */# pragma warning(disable: 4514) /* unreferenced inline/local function has been removed */# pragma warning(disable: 4800) /* 'type' : forcing value to bool 'true' or 'false' (performance warning) */# pragma warning(disable: 4097) /* typedef-name 'identifier1' used as synonym for class-name 'identifier2' */# pragma warning(disable: 4706) /* assignment within conditional expression */# pragma warning(disable: 4786) /* truncating debug info after 255 characters */# pragma warning(disable: 4660) /* template-class specialization 'identifier' is already instantiated */# pragma warning(disable: 4355) /* 'this' : used in base member initializer list */# pragma warning(disable: 4231) /* nonstandard extension used : 'extern' before template explicit instantiation */# pragma warning(disable: 4710) /* function not inlined */# pragma warning(disable: 4530) /* C++ exception handler used, but unwind semantics are not enabled. Specify -GX */# elif defined(Q_CC_BOR)# pragma option -w-inl# pragma option -w-aus# pragma warn -inl# pragma warn -pia# pragma warn -ccc# pragma warn -rch# pragma warn -sig# endif#endifclass Q_CORE_EXPORT QFlag{ int i;public: inline QFlag(int i); inline operator int() const { return i; }};inline QFlag::QFlag(int ai) : i(ai) {}#ifndef Q_NO_TYPESAFE_FLAGStemplate<typename Enum>class QFlags{ typedef void **Zero; int i;public: typedef Enum enum_type; inline QFlags(const QFlags &f) : i(f.i) {} inline QFlags(Enum f) : i(f) {} inline QFlags(Zero = 0) : i(0) {} inline QFlags(QFlag f) : i(f) {} inline QFlags &operator=(const QFlags &f) { i = f.i; return *this; } inline QFlags &operator&=(int mask) { i &= mask; return *this; } inline QFlags &operator&=(uint mask) { i &= mask; return *this; } inline QFlags &operator|=(QFlags f) { i |= f.i; return *this; } inline QFlags &operator|=(Enum f) { i |= f; return *this; } inline QFlags &operator^=(QFlags f) { i ^= f.i; return *this; } inline QFlags &operator^=(Enum f) { i ^= f; return *this; } inline operator int() const { return i; } inline QFlags operator|(QFlags f) const { QFlags g; g.i = i | f.i; return g; } inline QFlags operator|(Enum f) const { QFlags g; g.i = i | f; return g; } inline QFlags operator^(QFlags f) const { QFlags g; g.i = i ^ f.i; return g; } inline QFlags operator^(Enum f) const { QFlags g; g.i = i ^ f; return g; } inline QFlags operator&(int mask) const { QFlags g; g.i = i & mask; return g; } inline QFlags operator&(uint mask) const { QFlags g; g.i = i & mask; return g; } inline QFlags operator&(Enum f) const { QFlags g; g.i = i & f; return g; } inline QFlags operator~() const { QFlags g; g.i = ~i; return g; } inline bool operator!() const { return !i; } inline bool testFlag(Enum f) const { return i & f; }private:#if QT_VERSION >= 0x050000 && !defined(Q_NO_DECLARED_NOT_DEFINED) explicit QFlags(bool);#endif};#define Q_DECLARE_FLAGS(Flags, Enum)\typedef QFlags<Enum> Flags;#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags) \inline QFlags<Flags::enum_type> operator|(Flags::enum_type f1, Flags::enum_type f2) \{ return QFlags<Flags::enum_type>(f1) | f2; } \inline QFlags<Flags::enum_type> operator|(Flags::enum_type f1, QFlags<Flags::enum_type> f2) \{ return f2 | f1; }#else /* Q_NO_TYPESAFE_FLAGS */#define Q_DECLARE_FLAGS(Flags, Enum)\typedef uint Flags;#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)#endif /* Q_NO_TYPESAFE_FLAGS */#if defined(Q_CC_GNU) && !defined(Q_CC_INTEL)/* make use of typeof-extension */template <typename T>class QForeachContainer {public: inline QForeachContainer(const T& t) : c(t), brk(0), i(c.begin()), e(c.end()) { } const T c; int brk; typename T::const_iterator i, e;};#define Q_FOREACH(variable, container) \for (QForeachContainer<__typeof__(container)> _container_(container); \ !_container_.brk && _container_.i != _container_.e; \ __extension__ ({ ++_container_.brk; ++_container_.i; })) \ for (variable = *_container_.i;; __extension__ ({--_container_.brk; break;}))#elsestruct QForeachContainerBase {};template <typename T>class QForeachContainer : public QForeachContainerBase {public: inline QForeachContainer(const T& t): c(t), brk(0), i(c.begin()), e(c.end()){}; const T c; mutable int brk; mutable typename T::const_iterator i, e; inline bool condition() const { return (!brk++ && i != e); }};template <typename T> inline T *qForeachPointer(const T &) { return 0; }template <typename T> inline QForeachContainer<T> qForeachContainerNew(const T& t){ return QForeachContainer<T>(t); }template <typename T>inline const QForeachContainer<T> *qForeachContainer(const QForeachContainerBase *base, const T *){ return static_cast<const QForeachContainer<T> *>(base); }#if (defined(Q_CC_MSVC) && !defined(Q_CC_MSVC_NET) && !defined(Q_CC_INTEL)) || defined(Q_CC_MIPS)/* Proper for-scoping in VC++6 and MIPSpro CC*/# define Q_FOREACH(variable,container) \ if(0){}else \ for (const QForeachContainerBase &_container_ = qForeachContainerNew(container); \ qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->condition(); \ ++qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->i) \ for (variable = *qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->i; \ qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->brk; \ --qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->brk)#else# define Q_FOREACH(variable, container) \ for (const QForeachContainerBase &_container_ = qForeachContainerNew(container); \ qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->condition(); \ ++qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->i) \ for (variable = *qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->i; \ qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->brk; \ --qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->brk)#endif // MSVC6 || MIPSpro#endif#define Q_FOREVER for(;;)#ifndef QT_NO_KEYWORDS# ifndef foreach# define foreach Q_FOREACH# endif# ifndef forever# define forever Q_FOREVER# endif#endif#if 0/* tell gcc to use its built-in methods for some common functions */#if defined(QT_NO_DEBUG) && defined(Q_CC_GNU)# define qMemCopy __builtin_memcpy# define qMemSet __builtin_memset#endif#endif#define Q_DECLARE_PRIVATE(Class) \ inline Class##Private* d_func() { return reinterpret_cast<Class##Private *>(d_ptr); } \ inline const Class##Private* d_func() const { return reinterpret_cast<const Class##Private *>(d_ptr); } \ friend class Class##Private;#define Q_DECLARE_PUBLIC(Class) \ inline Class* q_func() { return static_cast<Class *>(q_ptr); } \ inline const Class* q_func() const { return static_cast<const Class *>(q_ptr); } \ friend class Class;#define Q_D(Class) Class##Private * const d = d_func()#define Q_Q(Class) Class * const q = q_func()#define QT_TR_NOOP(x) (x)#define QT_TRANSLATE_NOOP(scope, x) (x)#define QDOC_PROPERTY(text)/* Some classes do not permit copies to be made of an object. These classes contains a private copy constructor and assignment operator to disable copying (the compiler gives an error message).*/#if !defined(Q_NO_DECLARED_NOT_DEFINED) || !defined(QT_MAKEDLL) #define Q_DISABLE_COPY(Class) \ Class(const Class &); \ Class &operator=(const Class &);#else #define Q_DISABLE_COPY(Class)#endifclass QByteArray;Q_CORE_EXPORT QByteArray qgetenv(const char *varName);inline int qIntCast(double f) { return int(f); }inline int qIntCast(float f) { return int(f); }/* Reentrant versions of basic rand() functions for random number generation*/Q_CORE_EXPORT void qsrand(uint seed);Q_CORE_EXPORT int qrand();/* Compat functions that were generated by configure*/#ifdef QT3_SUPPORT#ifndef QT_PRODUCT_LICENSEE# define QT_PRODUCT_LICENSEE QLibraryInfo::licensee()#endif#ifndef QT_PRODUCT_LICENSE# define QT_PRODUCT_LICENSE QLibraryInfo::licensedProducts()#endifQT3_SUPPORT Q_CORE_EXPORT const char *qInstallPath();QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPathDocs();QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPathHeaders();QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPathLibs();QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPathBins();QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPathPlugins();QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPathData();QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPathTranslations();QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPathSysconf();#endif/* This gives us the possibility to check which modules the user can use. These are purely compile time checks and will generate no code.*//* Qt modules */#define QT_MODULE_CORE 0x001#define QT_MODULE_GUI 0x002#define QT_MODULE_NETWORK 0x004#define QT_MODULE_OPENGL 0x008#define QT_MODULE_SQL 0x010#define QT_MODULE_XML 0x020#define QT_MODULE_QT3SUPPORTLIGHT 0x040#define QT_MODULE_QT3SUPPORT 0x080#define QT_MODULE_SVG 0x100#define QT_MODULE_ACTIVEQT 0x200#define QT_MODULE_GRAPHICSVIEW 0x400#define QT_MODULE_SCRIPT 0x800/* Qt editions */#define QT_EDITION_CONSOLE (QT_MODULE_CORE \ | QT_MODULE_NETWORK \ | QT_MODULE_SQL \ | QT_MODULE_SCRIPT \ | QT_MODULE_XML)#define QT_EDITION_DESKTOPLIGHT (QT_MODULE_CORE \ | QT_MODULE_GUI \ | QT_MODULE_QT3SUPPORTLIGHT)#define QT_EDITION_OPENSOURCE (QT_MODULE_CORE \ | QT_MODULE_GUI \ | QT_MODULE_NETWORK \ | QT_MODULE_OPENGL \ | QT_MODULE_SQL \ | QT_MODULE_XML \ | QT_MODULE_SCRIPT \ | QT_MODULE_QT3SUPPORTLIGHT \ | QT_MODULE_QT3SUPPORT \ | QT_MODULE_SVG \ | QT_MODULE_GRAPHICSVIEW)#define QT_EDITION_DESKTOP (QT_EDITION_OPENSOURCE \ | QT_MODULE_ACTIVEQT)#define QT_EDITION_UNIVERSAL QT_EDITION_DESKTOP#define QT_EDITION_ACADEMIC QT_EDITION_DESKTOP#define QT_EDITION_EDUCATIONAL QT_EDITION_DESKTOP#define QT_EDITION_EVALUATION QT_EDITION_DESKTOP/* Determine which modules can be used */#ifndef QT_EDITION# ifdef QT_BUILD_QMAKE# define QT_EDITION QT_EDITION_DESKTOP# else# error "Qt not configured correctly, please run configure"# endif#endif#define QT_LICENSED_MODULE(x) \ enum QtValidLicenseFor##x##Module { Licensed##x = true };#if (QT_EDITION & QT_MODULE_CORE)QT_LICENSED_MODULE(Core)#endif#if (QT_EDITION & QT_MODULE_GUI)QT_LICENSED_MODULE(Gui)#endif#if (QT_EDITION & QT_MODULE_NETWORK)QT_LICENSED_MODULE(Network)#endif#if (QT_EDITION & QT_MODULE_OPENGL)QT_LICENSED_MODULE(OpenGL)#endif#if (QT_EDITION & QT_MODULE_SQL)QT_LICENSED_MODULE(Sql)#endif#if (QT_EDITION & QT_MODULE_XML)QT_LICENSED_MODULE(Xml)#endif#if (QT_EDITION & QT_MODULE_SCRIPT) || defined(QT_BUILD_QMAKE)QT_LICENSED_MODULE(Script)#endif#if (QT_EDITION & QT_MODULE_QT3SUPPORTLIGHT)QT_LICENSED_MODULE(Qt3SupportLight)#endif#if (QT_EDITION & QT_MODULE_QT3SUPPORT)QT_LICENSED_MODULE(Qt3Support)#endif#if (QT_EDITION & QT_MODULE_SVG)QT_LICENSED_MODULE(Svg)#endif#if (QT_EDITION & QT_MODULE_ACTIVEQT)QT_LICENSED_MODULE(ActiveQt)#endif#define QT_MODULE(x) \ typedef QtValidLicenseFor##x##Module Qt##x##Module;QT_END_HEADER#endif /* __cplusplus */#endif /* QGLOBAL_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -