⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qapplication.cpp

📁 qt-x11-opensource-src-4.1.4.tar.gz源码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
Q_GLOBAL_STATIC(PaletteHash, app_palettes)PaletteHash *qt_app_palettes_hash(){    return app_palettes();}typedef QHash<QByteArray, QFont> FontHash;Q_GLOBAL_STATIC(FontHash, app_fonts)FontHash *qt_app_fonts_hash(){    return app_fonts();}QWidgetList *QApplicationPrivate::popupWidgets = 0;        // has keyboard input focusQDesktopWidget *qt_desktopWidget = 0;                // root window widgets#ifndef QT_NO_CLIPBOARDQClipboard              *qt_clipboard = 0;        // global clipboard object#endifQWidgetList * qt_modal_stack=0;                // stack of modal widgets/*!    \internal*/void QApplicationPrivate::process_cmdline(){    Q_Q(QApplication);    // process platform-indep command line    if (!qt_is_gui_used || !argc)        return;    int i, j;    j = 1;    for (i=1; i<argc; i++) { // if you add anything here, modify QCoreApplication::arguments()        if (argv[i] && *argv[i] != '-') {            argv[j++] = argv[i];            continue;        }        QByteArray arg = argv[i];        arg = arg;        QString s;        if (arg == "-qdevel" || arg == "-qdebug") {            // obsolete argument        } else if (arg.indexOf("-style=", 0) != -1) {            s = QString::fromLocal8Bit(arg.right(arg.length() - 7).toLower());        } else if (arg == "-style" && i < argc-1) {            s = QString::fromLocal8Bit(argv[++i]).toLower();#ifndef QT_NO_SESSIONMANAGER        } else if (arg == "-session" && i < argc-1) {            ++i;            if (argv[i] && *argv[i]) {                session_id = QString::fromLatin1(argv[i]);                int p = session_id.indexOf(QLatin1Char('_'));                if (p >= 0) {                    session_key = session_id.mid(p +1);                    session_id = session_id.left(p);                }                is_session_restored = true;            }#endif        } else if (qstrcmp(arg, "-reverse") == 0) {            force_reverse = true;            q->setLayoutDirection(Qt::RightToLeft);        } else if (qstrcmp(arg, "-widgetcount") == 0) {            widgetCount = true;        } else {            argv[j++] = argv[i];        }        if (!s.isEmpty()) {            if (!styleOverride)                styleOverride = new QString;            *styleOverride = s;        }    }    if(j < argc) {        argv[j] = 0;        argc = j;    }}/*!  Initializes the window system and constructs an application object  with \a argc command line arguments in \a argv.  The global \c qApp pointer refers to this application object. Only  one application object should be created.  This application object must be constructed before any \link  QPaintDevice paint devices\endlink (including widgets, pixmaps, bitmaps  etc.).  Note that \a argc and \a argv might be changed. Qt removes command  line arguments that it recognizes. The original \a argc and \a argv  can be accessed later with \c qApp->argc() and \c qApp->argv().  The documentation for argv() contains a detailed description of how  to process command line arguments.  Qt debugging options (not available if Qt was compiled without the  QT_DEBUG flag defined):  \list  \o -nograb, tells Qt that it must never grab the mouse or the keyboard.  \o -dograb (only under X11), running under a debugger can cause  an implicit -nograb, use -dograb to override.  \o -sync (only under X11), switches to synchronous mode for        debugging.  \endlist  See \link debug.html Debugging Techniques \endlink for a more  detailed explanation.  All Qt programs automatically support the following command line options:  \list  \o -style= \e style, sets the application GUI style. Possible values       are \c motif, \c windows, and \c platinum. If you compiled Qt       with additional styles or have additional styles as plugins these       will be available to the \c -style command line option.  \o -style \e style, is the same as listed above.  \o -session= \e session, restores the application from an earlier       \link session.html session \endlink.  \o -session \e session, is the same as listed above.  \o -widgetcount, prints debug message at the end about number of widgets left       undestroyed and maximum number of widgets existed at the same time  \endlist  The X11 version of Qt also supports some traditional X11  command line options:  \list  \o -display \e display, sets the X display (default is $DISPLAY).  \o -geometry \e geometry, sets the client geometry of the        first window that is shown.  \o -fn or \c -font \e font, defines the application font. The  font should be specified using an X logical font description.  \o -bg or \c -background \e color, sets the default background color        and an application palette (light and dark shades are calculated).  \o -fg or \c -foreground \e color, sets the default foreground color.  \o -btn or \c -button \e color, sets the default button color.  \o -name \e name, sets the application name.  \o -title \e title, sets the application title.  \o -visual \c TrueColor, forces the application to use a TrueColor visual       on an 8-bit display.  \o -ncols \e count, limits the number of colors allocated in the       color cube on an 8-bit display, if the application is using the       QApplication::ManyColor color specification. If \e count is       216 then a 6x6x6 color cube is used (i.e. 6 levels of red, 6 of green,       and 6 of blue); for other values, a cube       approximately proportional to a 2x3x1 cube is used.  \o -cmap, causes the application to install a private color map       on an 8-bit display.  \endlist  \sa argc(), argv()*/QApplication::QApplication(int &argc, char **argv)    : QCoreApplication(*new QApplicationPrivate(argc, argv, GuiClient)){ Q_D(QApplication); d->construct(); }/*!    Constructs an application object with \a argc command line arguments    in \a argv. If \a GUIenabled is true, a GUI application is    constructed, otherwise a non-GUI (console) application is created.    Set \a GUIenabled to false for programs without a graphical user    interface that should be able to run without a window system.    On X11, the window system is initialized if \a GUIenabled is true.    If \a GUIenabled is false, the application does not connect to the    X server. On Windows and Macintosh, currently the window system is    always initialized, regardless of the value of GUIenabled. This may    change in future versions of Qt.    The following example shows how to create an application that    uses a graphical interface when available.    \code        int main(int argc, char **argv)        {        #ifdef Q_WS_X11            bool useGUI = getenv("DISPLAY") != 0;        #else            bool useGUI = true;        #endif            QApplication app(argc, argv, useGUI);            if (useGUI) {               // start GUI version               ...            } else {               // start non-GUI version               ...            }            return app.exec();        }    \endcode*/QApplication::QApplication(int &argc, char **argv, bool GUIenabled )    : QCoreApplication(*new QApplicationPrivate(argc, argv, GUIenabled ? GuiClient : Tty)){ Q_D(QApplication); d->construct(); }/*!  Constructs an application object with \a argc command line arguments  in \a argv.  For Qtopia Core, passing QApplication::GuiServer for \a type  makes this application the server (equivalent to running with the  \c -qws option).*/QApplication::QApplication(int &argc, char **argv, Type type)    : QCoreApplication(*new QApplicationPrivate(argc, argv, type)){ Q_D(QApplication); d->construct(); }/*!    \internal*/void QApplicationPrivate::construct(#ifdef Q_WS_X11                                    Display *dpy, Qt::HANDLE visual, Qt::HANDLE cmap#endif                                    ){    Q_INIT_RESOURCE(qstyle);    qt_is_gui_used = (qt_appType != QApplication::Tty);    process_cmdline();    // Must be called before initialize()    qt_init(this, qt_appType#ifdef Q_WS_X11            , dpy, visual, cmap#endif            );    initialize();    if (qt_is_gui_used)        qt_maxWindowRect = QApplication::desktop()->rect();    eventDispatcher->startingUp();#ifdef QT_EVAL    extern void qt_gui_eval_init(uint);    qt_gui_eval_init(application_type);#endif}#if defined(Q_WS_X11)// ### a string literal is a cont char*// ### using it as a char* is wrong and could lead to segfaults// ### if aargv is modified someday// ########## make it work with argc == argv == 0static int aargc = 1;static char *aargv[] = { (char*)"unknown", 0 };/*!  \fn QApplication::QApplication(Display* display, Qt::HANDLE visual, Qt::HANDLE colormap)  Create an application, given an already open display \a display. If \a  visual and \a colormap are non-zero, the application will use those as  the default Visual and Colormap contexts.  \warning Qt only supports TrueColor visuals at depths higher than 8  bits-per-pixel.  This is available only on X11.*/QApplication::QApplication(Display* dpy, Qt::HANDLE visual, Qt::HANDLE colormap)    : QCoreApplication(*new QApplicationPrivate(aargc, aargv, GuiClient)){    if (! dpy)        qWarning("QApplication: invalid Display* argument.");    Q_D(QApplication);    d->construct(dpy, visual, colormap);}/*!  \fn QApplication::QApplication(Display *display, int &argc, char **argv,                           Qt::HANDLE visual, Qt::HANDLE colormap)  Create an application, given an already open \a display and using \a  argc command line arguments in \a argv. If \a visual and \a colormap  are non-zero, the application will use those as the default Visual  and Colormap contexts.  \warning Qt only supports TrueColor visuals at depths higher than 8  bits-per-pixel.  This is available only on X11.*/QApplication::QApplication(Display *dpy, int &argc, char **argv,                           Qt::HANDLE visual, Qt::HANDLE colormap)    : QCoreApplication(*new QApplicationPrivate(argc, argv, GuiClient)){    if (! dpy)        qWarning("QApplication: invalid Display* argument.");    Q_D(QApplication);    d->construct(dpy, visual, colormap);}#endif // Q_WS_X11/*!  Initializes the QApplication object, called from the constructors.*/void QApplicationPrivate::initialize(){    QWidgetPrivate::mapper = new QWidgetMapper;    if (qt_appType != QApplication::Tty)        (void) QApplication::style();  // trigger creation of application style    // trigger registering of QVariant's GUI types    extern int qRegisterGuiVariant();    qRegisterGuiVariant();    is_app_running = true; // no longer starting up#ifndef QT_NO_SESSIONMANAGER    // connect to the session manager    Q_Q(QApplication);    session_manager = new QSessionManager(q, session_id, session_key);#endif}/*!    Returns the type of application (\l Tty, GuiClient, or    GuiServer). The type is set when constructing the QApplication    object.*/QApplication::Type QApplication::type(){    return qt_appType;}/*****************************************************************************  Functions returning the active popup and modal widgets. *****************************************************************************//*!  Returns the active popup widget.  A popup widget is a special top-level widget that sets the \c  Qt::WType_Popup widget flag, e.g. the QMenu widget. When the  application opens a popup widget, all events are sent to the popup.  Normal widgets and modal widgets cannot be accessed before the popup  widget is closed.  Only other popup widgets may be opened when a popup widget is shown.  The popup widgets are organized in a stack. This function returns  the active popup widget at the top of the stack.  \sa activeModalWidget(), topLevelWidgets()*/QWidget *QApplication::activePopupWidget(){    return QApplicationPrivate::popupWidgets && !QApplicationPrivate::popupWidgets->isEmpty() ?        QApplicationPrivate::popupWidgets->last() : 0;}/*!  Returns the active modal widget.  A modal widget is a special top-level widget which is a subclass of  QDialog that specifies the modal parameter of the constructor as  true. A modal widget must be closed before the user can continue  with other parts of the program.  Modal widgets are organized in a stack. This function returns  the active modal widget at the top of the stack.  \sa activePopupWidget(), topLevelWidgets()*/QWidget *QApplication::activeModalWidget(){    return qt_modal_stack && !qt_modal_stack->isEmpty() ? qt_modal_stack->first() : 0;}/*!  Cleans up any window system resources that were allocated by this  application. Sets the global variable \c qApp to 0.*/QApplication::~QApplication(){    Q_D(QApplication);#ifndef QT_NO_CLIPBOARD    // flush clipboard contents    if (qt_clipboard) {        QEvent event(QEvent::Clipboard);        QApplication::sendEvent(qt_clipboard, &event);    }#endif    //### this should probable be done even later    qt_call_post_routines();    // kill timers before closing down the dispatcher    d->toolTipWakeUp.stop();    d->toolTipFallAsleep.stop();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -