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

📄 qapplication.cpp

📁 qt-x11-opensource-src-4.1.4.tar.gz源码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
    (e.g. it requires thousands of colors).    Under X11 the effect is:    \list    \o For 256-color displays which have at best a 256 color true       color visual, the default visual is used, and colors are       allocated from a color cube. The color cube is the 6x6x6 (216       color) "Web palette" (the red, green, and blue components       always have one of the following values: 0x00, 0x33, 0x66,       0x99, 0xCC, or 0xFF), but the number of colors can be changed       by the \e -ncols option. The user can force the application to       use the true color visual with the \link       QApplication::QApplication() -visual \endlink option.    \o For 256-color displays which have a true color visual with more       than 256 colors, use that visual. Silicon Graphics X servers       have this feature, for example. They provide an 8 bit visual       by default but can deliver true color when asked.    \endlist    On Windows, Qt creates a Windows palette, and fills it with a color cube.  \endlist  Be aware that the CustomColor and ManyColor choices may lead to colormap  flashing: The foreground application gets (most) of the available  colors, while the background windows will look less attractive.  Example:    \code        int main(int argc, char *argv[])        {            QApplication::setColorSpec(QApplication::ManyColor);            QApplication app(argc, argv);            ...            return app.exec();        }    \endcode    \sa colorSpec()*/void QApplication::setColorSpec(int spec){    if (qApp)        qWarning("QApplication::setColorSpec: This function must be "                 "called before the QApplication object is created");    QApplicationPrivate::app_cspec = spec;}/*!    \property QApplication::globalStrut    \brief the minimum size that any GUI element that the user can interact           with should have    For example no button should be resized to be smaller than the    global strut size. The strut size should be considered when    reimplementing GUI controls that may be used on touch-screens or    similar I/O devices.    Example:    \code        QSize MyWidget::sizeHint() const        {            return QSize(80, 25).expandedTo(QApplication::globalStrut());        }    \endcode*/QSize QApplication::globalStrut(){    return QApplicationPrivate::app_strut;}void QApplication::setGlobalStrut(const QSize& strut){    QApplicationPrivate::app_strut = strut;}/*!    Returns the application palette.    \sa setPalette(), QWidget::palette()*/QPalette QApplication::palette(){    QApplicationPrivate::checkInstance("palette");    if (!QApplicationPrivate::app_pal)        QApplicationPrivate::app_pal = new QPalette(Qt::black);    return *QApplicationPrivate::app_pal;}/*!    \fn QPalette QApplication::palette(const QWidget* widget)    \overload    If a \a widget is passed, the default palette for the    widget's class is returned. This may or may not be the application    palette. In most cases there isn't a special palette for certain    types of widgets, but one notable exception is the popup menu    under Windows, if the user has defined a special background color    for menus in the display settings.    \sa setPalette(), QWidget::palette()*/QPalette QApplication::palette(const QWidget* w){    PaletteHash *hash = app_palettes();    if (w && hash && hash->size()) {        QHash<QByteArray, QPalette>::ConstIterator it = hash->find(w->metaObject()->className());        if (it != hash->constEnd())            return *it;        for (it = hash->constBegin(); it != hash->constEnd(); ++it) {            if (w->inherits(it.key()))                return it.value();        }    }    return palette();}/*!    \overload    Returns the palette for widgets of the given \a className.    \sa setPalette(), QWidget::palette()*/QPalette QApplication::palette(const char *className){    if (!QApplicationPrivate::app_pal)        palette();    PaletteHash *hash = app_palettes();    if (className && hash && hash->size()) {        QHash<QByteArray, QPalette>::ConstIterator it = hash->find(className);        if (it != hash->constEnd())            return *it;    }    return *QApplicationPrivate::app_pal;}void QApplicationPrivate::setPalette_helper(const QPalette &palette, const char* className, bool clearWidgetPaletteHash){    QPalette pal = palette;    if (QApplicationPrivate::app_style)        QApplicationPrivate::app_style->polish(pal); // NB: non-const reference    bool all = false;    PaletteHash *hash = app_palettes();    if (!className) {        if (QApplicationPrivate::app_pal && pal.isCopyOf(*QApplicationPrivate::app_pal))            return;        if (!QApplicationPrivate::app_pal)            QApplicationPrivate::app_pal = new QPalette(pal);        else            *QApplicationPrivate::app_pal = pal;        if (hash && hash->size()) {            all = true;            if (clearWidgetPaletteHash)                hash->clear();        }    } else if (hash) {        hash->insert(className, pal);    }    if (QApplicationPrivate::is_app_running && !QApplicationPrivate::is_app_closing) {        QEvent e(QEvent::ApplicationPaletteChange);        for (QWidgetMapper::ConstIterator it = QWidgetPrivate::mapper->constBegin();             it != QWidgetPrivate::mapper->constEnd(); ++it) {            register QWidget *w = *it;            if (all || (!className && w->isWindow()) || w->inherits(className)) // matching class                QApplication::sendEvent(w, &e);        }    }    if (!className && (!QApplicationPrivate::sys_pal || !palette.isCopyOf(*QApplicationPrivate::sys_pal))) {        if (!QApplicationPrivate::set_pal)            QApplicationPrivate::set_pal = new QPalette(palette);        else            *QApplicationPrivate::set_pal = palette;    }}/*!  Changes the default application palette to \a palette.  If \a className is passed, the change applies only to widgets that  inherit \a className (as reported by QObject::inherits()). If  \a className is left 0, the change affects all widgets, thus overriding  any previously set class specific palettes.  The palette may be changed according to the current GUI style in  QStyle::polish().  \sa QWidget::setPalette(), palette(), QStyle::polish()*/void QApplication::setPalette(const QPalette &palette, const char* className){    QApplicationPrivate::setPalette_helper(palette, className, /*clearWidgetPaletteHash=*/ true);}void QApplicationPrivate::setSystemPalette(const QPalette &pal){    QPalette adjusted;#if 0    // adjust the system palette to avoid dithering    QColormap cmap = QColormap::instance();    if (cmap.depths() > 4 && cmap.depths() < 24) {        for (int g = 0; g < QPalette::NColorGroups; g++)            for (int i = 0; i < QPalette::NColorRoles; i++) {                QColor color = pal.color((QPalette::ColorGroup)g, (QPalette::ColorRole)i);                color = cmap.colorAt(cmap.pixel(color));                adjusted.setColor((QPalette::ColorGroup)g, (QPalette::ColorRole) i, color);            }    }#else    adjusted = pal;#endif    if (!sys_pal)        sys_pal = new QPalette(adjusted);    else        *sys_pal = adjusted;    if (!QApplicationPrivate::set_pal)        QApplication::setPalette(*sys_pal);}/*!  \fn QFont QApplication::font(const QWidget *widget)  Returns the default font for the \a widget, or the default  application font if \a widget is 0.  \sa setFont(), fontMetrics(), QWidget::font()*/QFont QApplication::font(const QWidget *w){    FontHash *hash = app_fonts();    if (w && hash  && hash->size()) {        QHash<QByteArray, QFont>::ConstIterator it =            hash->find(w->metaObject()->className());        if (it != hash->constEnd())            return it.value();        for (it = hash->begin(); it != hash->end(); ++it) {            if (w->inherits(it.key()))                return it.value();        }    }    if (!QApplicationPrivate::app_font)        QApplicationPrivate::app_font = new QFont(QLatin1String("Helvetica"));    return *QApplicationPrivate::app_font;}/*! Changes the default application font to \a font.  If \a className  is passed, the change applies only to classes that inherit \a  className (as reported by QObject::inherits()).  On application start-up, the default font depends on the window  system. It can vary depending on both the window system version and  the locale. This function lets you override the default font; but  overriding may be a bad idea because, for example, some locales need  extra-large fonts to support their special characters.  \sa font(), fontMetrics(), QWidget::setFont()*/void QApplication::setFont(const QFont &font, const char* className){    bool all = false;    FontHash *hash = app_fonts();    if (!className) {        qt_app_has_font = true;        if (!QApplicationPrivate::app_font)            QApplicationPrivate::app_font = new QFont(font);        else            *QApplicationPrivate::app_font = font;        if (hash && hash->size()) {            all = true;            hash->clear();        }    } else if (hash) {        hash->insert(className, font);    }    if (QApplicationPrivate::is_app_running && !QApplicationPrivate::is_app_closing) {        QEvent e(QEvent::ApplicationFontChange);        for (QWidgetMapper::ConstIterator it = QWidgetPrivate::mapper->constBegin();             it != QWidgetPrivate::mapper->constEnd(); ++it) {            register QWidget *w = *it;            if (all || (!className && w->isWindow()) || w->inherits(className)) // matching class                sendEvent(w, &e);        }    }}/*!    \property QApplication::windowIcon    \brief the default window icon    \sa QWidget::setWindowIcon(), {Setting the Application Icon}*/QIcon QApplication::windowIcon(){    return QApplicationPrivate::app_icon ? *QApplicationPrivate::app_icon : QIcon();}void QApplication::setWindowIcon(const QIcon &icon){    if (!QApplicationPrivate::app_icon)        QApplicationPrivate::app_icon = new QIcon();    *QApplicationPrivate::app_icon = icon;    if (QApplicationPrivate::is_app_running && !QApplicationPrivate::is_app_closing) {#ifdef Q_WS_MAC        void qt_mac_set_app_icon(const QPixmap &); //qapplication_mac.cpp        QSize size = QApplicationPrivate::app_icon->actualSize(QSize(64, 64));        qt_mac_set_app_icon(QApplicationPrivate::app_icon->pixmap(size));#endif        QEvent e(QEvent::ApplicationWindowIconChange);        for (QWidgetMapper::ConstIterator it = QWidgetPrivate::mapper->constBegin();             it != QWidgetPrivate::mapper->constEnd(); ++it) {            register QWidget *w = *it;            if (w->isWindow())                sendEvent(w, &e);        }    }}/*!    Returns a list of the top-level widgets (windows) in the    application.    Note that some of the top-level widgets may be hidden, for    example a tooltip if no tooltip is currently shown.    Example:    \code        void showAllHiddenTopLevelWidgets()        {            foreach (QWidget *widget, QApplication::topLevelWidgets()) {                if (widget->isHidden())                    widget->show();            }        }    \endcode    \sa allWidgets(), QWidget::isWindow(), QWidget::isHidden()*/QWidgetList QApplication::topLevelWidgets(){    QWidgetList list;    if (QWidgetPrivate::mapper) {        for (QWidgetMapper::ConstIterator it = QWidgetPrivate::mapper->constBegin();             it != QWidgetPrivate::mapper->constEnd(); ++it) {            QWidget *w = *it;            if (w->isWindow())                list.append(w);        }    }    return list;}/*!    Returns a list of all the widgets in the application.    The list is empty (QList::isEmpty()) if there are no widgets.    Note that some of the widgets may be hidden.    Example:    \code        void updateAllWidgets()        {            foreach (QWidget *widget, QApplication::allWidgets())                widget->update();        }    \endcode    \sa topLevelWidgets(), QWidget::isVisible()*/QWidgetList QApplication::allWidgets(){    QWidgetList list;    if (QWidgetPrivate::mapper) {        for (QWidgetMapper::ConstIterator it = QWidgetPrivate::mapper->constBegin();             it != QWidgetPrivate::mapper->constEnd(); ++it)            list.append(*it);    }    return list;}/*!  Returns the application widget that has the keyboard input focus, or  0 if no widget in this application has the focus.  \sa QWidget::setFocus(), QWidget::hasFocus(), activeWindow(), focusChanged()*/QWidget *QApplication::focusWidget(){    return QApplicationPrivate::focus_widget;

⌨️ 快捷键说明

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