当前位置: 代码迷 >> QT开发 >> QApplication 的种class后,为什么有个 Q_GUI_EXPORT
  详细解决方案

QApplication 的种class后,为什么有个 Q_GUI_EXPORT

热度:376   发布时间:2016-04-25 04:41:22.0
QApplication 的类class后,为什么有个 Q_GUI_EXPORT?
RT。。。
一般是: 
class 变量名 : public XXX
{

}

为什么QT 的QApplication 前面有个 “Q_GUI_EXPORT”, 做什么用的,如何理解?
C/C++ code
class Q_GUI_EXPORT QApplication : public QCoreApplication{    Q_OBJECT    Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection)    Q_PROPERTY(QIcon windowIcon READ windowIcon WRITE setWindowIcon)    Q_PROPERTY(int cursorFlashTime READ cursorFlashTime WRITE setCursorFlashTime)    Q_PROPERTY(int doubleClickInterval  READ doubleClickInterval WRITE setDoubleClickInterval)    Q_PROPERTY(int keyboardInputInterval READ keyboardInputInterval WRITE setKeyboardInputInterval)#ifndef QT_NO_WHEELEVENT    Q_PROPERTY(int wheelScrollLines  READ wheelScrollLines WRITE setWheelScrollLines)#endif    Q_PROPERTY(QSize globalStrut READ globalStrut WRITE setGlobalStrut)    Q_PROPERTY(int startDragTime  READ startDragTime WRITE setStartDragTime)    Q_PROPERTY(int startDragDistance  READ startDragDistance WRITE setStartDragDistance)    Q_PROPERTY(bool quitOnLastWindowClosed  READ quitOnLastWindowClosed WRITE setQuitOnLastWindowClosed)#ifndef QT_NO_STYLE_STYLESHEET    Q_PROPERTY(QString styleSheet READ styleSheet WRITE setStyleSheet)#endif#ifdef Q_WS_WINCE    Q_PROPERTY(int autoMaximizeThreshold READ autoMaximizeThreshold WRITE setAutoMaximizeThreshold)#endif    Q_PROPERTY(bool autoSipEnabled READ autoSipEnabled WRITE setAutoSipEnabled)


------解决方案--------------------
既然都看源码了,我想你应该知道windows下的动态库如何编写吧?(如果你真的不用windows,忽略它即可)
------解决方案--------------------
那是个宏定义
如:
#include <QtCore/qglobal.h>

#if defined DLL
#define Q_GUI_EXPORT __declspec(dllexport)//导出
#else
#define Q_GUI_EXPORT __declspec(dllimport)//导入

如果在编写动态库时,定义DLL符号,Q_GUI_EXPORT就是导出函数或者类了
如果在应用程序中使用时,不定义Dll符号,Q_GUI_EXPORT就是导入类或者函数了

  相关解决方案