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

📄 qaction.cpp

📁 qt-x11-opensource-src-4.1.4.tar.gz源码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
        s = d->iconText;        s.replace(QLatin1Char('&'), QLatin1String("&&"));    }    return s;}/*!    \property QAction::iconText    \brief the action's descriptive icon text    If QToolBar::toolButtonStyle is set to a value that permits text to    be displayed, the text defined held in this property appears as a    label in the relevant tool button.    It also serves as the default text in menus and tooltips if the action    has not been defined with setText() or setToolTip(), and will    also be used in toolbar buttons if no icon has been defined using setIcon().    If the icon text is not explicitly set, the action's normal text will be    used for the icon text.    There is no default icon text.    \sa setToolTip(), setStatusTip()*/void QAction::setIconText(const QString &text){    Q_D(QAction);    if (d->iconText == text)        return;    d->iconText = text;    d->sendDataChanged();}QString QAction::iconText() const{    Q_D(const QAction);    if (d->iconText.isEmpty())        return qt_strippedText(d->text);    return d->iconText;}/*!    \property QAction::toolTip    \brief the action's tooltip    This text is used for the tooltip. If no tooltip is specified,    the action's text is used.    \sa setStatusTip() setShortcut()*/void QAction::setToolTip(const QString &tooltip){    Q_D(QAction);    if (d->tooltip == tooltip)        return;    d->tooltip = tooltip;    d->sendDataChanged();}QString QAction::toolTip() const{    Q_D(const QAction);    if (d->tooltip.isEmpty()) {        if (!d->text.isEmpty())            return qt_strippedText(d->text);        return d->iconText;    }    return d->tooltip;}/*!    \property QAction::statusTip    \brief the action's status tip    The status tip is displayed on all status bars provided by the    action's top-level parent widget.    \sa setToolTip() showStatusText()*/void QAction::setStatusTip(const QString &statustip){    Q_D(QAction);    if (d->statustip == statustip)        return;    d->statustip = statustip;    d->sendDataChanged();}QString QAction::statusTip() const{    Q_D(const QAction);    return d->statustip;}/*!    \property QAction::whatsThis    \brief the action's "What's This?" help text    The "What's This?" text is used to provide a brief description of    the action. The text may contain rich text. There is no default    "What's This?" text.    \sa QWhatsThis QStyleSheet*/void QAction::setWhatsThis(const QString &whatsthis){    Q_D(QAction);    if (d->whatsthis == whatsthis)        return;    d->whatsthis = whatsthis;    d->sendDataChanged();}QString QAction::whatsThis() const{    Q_D(const QAction);    return d->whatsthis;}/*!    \property QAction::checkable    \brief whether the action is a checkable action    A checkable action is one which has an on/off state. For example,    in a word processor, a Bold toolbar button may be either on or    off. An action which is not a toggle action is a command action;    a command action is simply executed, e.g. file save.    By default, this property is false.    In some situations, the state of one toggle action should depend    on the state of others. For example, "Left Align", "Center" and    "Right Align" toggle actions are mutually exclusive. To achieve    exclusive toggling, add the relevant toggle actions to a    QActionGroup with the QActionGroup::exclusive property set to    true.    \sa QAction::setChecked()*/void QAction::setCheckable(bool b){    Q_D(QAction);    if (d->checkable == b)        return;    d->checkable = b;    d->checked = false;    d->sendDataChanged();}bool QAction::isCheckable() const{    Q_D(const QAction);    return d->checkable;}/*!    \fn void QAction::toggle()    This is a convenience function for the \l checked property.    Connect to it to change the checked state to its opposite state.*/void QAction::toggle(){    Q_D(QAction);    setChecked(!d->checked);}/*!    \property QAction::checked    \brief whether the action is checked.    Only checkable actions can be checked.  By default, this is false    (the action is unchecked).    \sa checkable*/void QAction::setChecked(bool b){    Q_D(QAction);    if (!d->checkable || d->checked == b)        return;    QPointer<QAction> guard(this);    d->checked = b;    d->sendDataChanged();    if (guard)        emit toggled(b);}bool QAction::isChecked() const{    Q_D(const QAction);    return d->checked;}/*!    \fn void QAction::setDisabled(bool b)    This is a convenience function for the \l enabled property, that    is useful for signals--slots connections. If \a b is true the    action is disabled; otherwise it is enabled.*//*!    \property QAction::enabled    \brief whether the action is enabled    Disabled actions cannot be chosen by the user. They do not    disappear from menus or toolbars, but they are displayed in a way    which indicates that they are unavailable. For example, they might    be displayed using only shades of gray.    What's this? help on disabled actions is still available, provided    that the QAction::whatsThis property is set.*/void QAction::setEnabled(bool b){    Q_D(QAction);    if (b == d->enabled && b != d->forceDisabled)        return;    d->forceDisabled = !b;    if (b && d->group && !d->group->isEnabled())        return;    d->enabled = b;#ifndef QT_NO_SHORTCUT    d->setShortcutEnabled(b, qApp->d_func()->shortcutMap);#endif    d->sendDataChanged();}bool QAction::isEnabled() const{    Q_D(const QAction);    return d->enabled;}/*!    \property QAction::visible    \brief whether the action can be seen (e.g. in menus and toolbars)    If \e visible is true the action can be seen (e.g. in menus and    toolbars) and chosen by the user; if \e visible is false the    action cannot be seen or chosen by the user.    Actions which are not visible are \e not grayed out; they do not    appear at all.*/void QAction::setVisible(bool b){    Q_D(QAction);    if (b == d->visible && b != d->forceInvisible)        return;    d->forceInvisible = !b;    d->visible = b;    d->sendDataChanged();}bool QAction::isVisible() const{    Q_D(const QAction);    return d->visible;}/*!  \reimp*/boolQAction::event(QEvent *e){#ifndef QT_NO_SHORTCUT    if (e->type() == QEvent::Shortcut) {        QShortcutEvent *se = static_cast<QShortcutEvent *>(e);        Q_ASSERT_X(se->key() == d_func()->shortcut,                   "QAction::event",                   "Received shortcut event from incorrect shortcut");        if (se->isAmbiguous())            qWarning("QAction::eventFilter: ambiguous shortcut overload: %s", QString(se->key()).toLatin1().constData());        else            activate(Trigger);        return true;    }#endif    return QObject::event(e);}/*!  Returns the user data as set in QAction::setData.  \sa setData()*/QVariantQAction::data() const{    Q_D(const QAction);    return d->userData;}/*!  Sets internal data to \a data. This can be used for user data to store anything that a  QVariant can store. The ownership of anything the the user data will remain with the  variant and thus be referenced counted as appropriate.  \sa data()*/voidQAction::setData(const QVariant &data){    Q_D(QAction);    d->userData = data;    d->sendDataChanged();}/*!  Updates the status bar for \a widget. If widget is an appropriate  QStatusBar found for for this action based on the parent heirarchy will be used.  \sa statusTip*/boolQAction::showStatusText(QWidget *widget){    if(QObject *object = widget ? widget : parent()) {        QStatusTipEvent tip(statusTip());        QApplication::sendEvent(object, &tip);        return true;    }    return false;}/*!  Sends the relevant signals for ActionEvent \a event.  Action based widgets use this API to cause the QAction  to emit signals as well as emitting their own.*/void QAction::activate(ActionEvent event){    Q_D(QAction);    if(event == Trigger) {        QObject *guard = this;        QMetaObject::addGuard(&guard);        if(d->checkable) {            // the checked action of an exclusive group cannot be  unchecked            if (d->checked && (d->group && d->group->isExclusive()                               && d->group->checkedAction() == this)) {                QMetaObject::removeGuard(&guard);                return;            }            setChecked(!d->checked);        }        if (guard)            emit triggered(d->checked);#ifdef QT3_SUPPORT        if (guard)            emit activated(d->param);#endif        QMetaObject::removeGuard(&guard);    } else if(event == Hover) {        emit hovered();    }}/*!    \fn void QAction::triggered(bool checked)    This signal is emitted when an action is activated by the user;    for example, when the user clicks a menu option, toolbar button,    or presses an action's shortcut key combination, or when trigger()    was called. Notably, it is \e not emitted when setChecked() or    toggle() is called.    If the action is checkable, \a checked is true if the action is    checked, or false if the action is unchecked.    \sa QAction::activate(), QAction::toggled(), checked*//*!    \fn void QAction::toggled(bool checked)    This signal is emitted whenever a checkable action changes its    isChecked() status. This can be the result of a user interaction,    or because setChecked() was called.    \a checked is true if the action is checked, or false if the    action is unchecked.    \sa QAction::activate(), QAction::triggered(), checked*//*!    \fn void QAction::hovered()    This signal is emitted when an action is highlighted by the user;    for example, when the user pauses with the cursor over a menu option,    toolbar button, or presses an action's shortcut key combination.    \sa QAction::activate()*//*!    \fn void QAction::changed()    This signal is emitted when an action has changed. If you    are only interested in actions in a given widget, you can    watch for QWidget::actionEvent() sent with an    QEvent::ActionChanged.    \sa QWidget::actionEvent()*//*!    \enum QAction::ActionEvent    This enum type is used when calling QAction::activate()    \value Trigger this will cause the QAction::triggered() signal to be emitted.    \value Hover this will cause the QAction::hovered() signal to be emitted.*//*!    \fn void QAction::setMenuText(const QString &text)    Use setText() instead.*//*!    \fn QString QAction::menuText() const    Use text() instead.*//*!    \fn bool QAction::isOn() const    Use isChecked() instead.*//*!    \fn void QAction::setOn(bool b)    Use setChecked() instead.*//*!    \fn bool QAction::isToggleAction() const    Use isCheckable() instead.*//*!    \fn void QAction::setToggleAction(bool b)    Use setCheckable() instead.*//*!    \fn void QAction::setIconSet(const QIcon &i)    Use setIcon() instead.*//*!    \fn bool QAction::addTo(QWidget *w)    Use QWidget::addAction() instead.    \oldcode    action->addTo(widget);    \newcode    widget->addAction(action);    \endcode*//*!    \fn bool QAction::removeFrom(QWidget *w)    Use QWidget::removeAction() instead.    \oldcode    action->removeFrom(widget);    \newcode    widget->removeAction(action);    \endcode*//*!    \fn void QAction::setAccel(const QKeySequence &shortcut)    Use setShortcut() instead.*//*!    \fn QIcon QAction::iconSet() const    Use icon() instead.*//*!    \fn QKeySequence QAction::accel() const    Use shortcut() instead.*//*!    \fn void QAction::activated(int i);    Use triggered() instead.*/#include "moc_qaction.cpp"#endif // QT_NO_ACTION

⌨️ 快捷键说明

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