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

📄 qabstractbutton.cpp

📁 奇趣公司比较新的qt/emd版本
💻 CPP
📖 第 1 页 / 共 3 页
字号:
{    Q_Q(QAbstractButton);    if (blockRefresh)        return;    q->update();#ifndef QT_NO_ACCESSIBILITY    QAccessible::updateAccessibility(q, 0, QAccessible::StateChanged);#endif}void QAbstractButtonPrivate::click(){    Q_Q(QAbstractButton);    down = false;    blockRefresh = true;    bool changeState = true;    if (checked && queryCheckedButton() == q) {        // the checked button of an exclusive or autoexclusive group cannot be unchecked#ifndef QT_NO_BUTTONGROUP        if (group ? group->d_func()->exclusive : autoExclusive)#else        if (autoExclusive)#endif            changeState = false;    }    QPointer<QAbstractButton> guard(q);    if (changeState) {        q->nextCheckState();        if (!guard)            return;    }    blockRefresh = false;    refresh();    q->repaint(); //flush paint event before invoking potentially expensive operation    QApplication::flush();    if (guard)        emitReleased();    if (guard)        emitClicked();}void QAbstractButtonPrivate::emitClicked(){    Q_Q(QAbstractButton);    QPointer<QAbstractButton> guard(q);    emit q->clicked(checked);#ifndef QT_NO_BUTTONGROUP    if (guard && group) {        emit group->buttonClicked(group->id(q));        emit group->buttonClicked(q);    }#endif}void QAbstractButtonPrivate::emitPressed(){    Q_Q(QAbstractButton);    QPointer<QAbstractButton> guard(q);    emit q->pressed();#ifndef QT_NO_BUTTONGROUP    if (guard && group) {        emit group->buttonPressed(group->id(q));        emit group->buttonPressed(q);    }#endif}void QAbstractButtonPrivate::emitReleased(){    Q_Q(QAbstractButton);    QPointer<QAbstractButton> guard(q);    emit q->released();#ifndef QT_NO_BUTTONGROUP    if (guard && group) {        emit group->buttonReleased(group->id(q));        emit group->buttonReleased(q);    }#endif}/*!    Constructs an abstract button with a \a parent.*/QAbstractButton::QAbstractButton(QWidget *parent)    : QWidget(*new QAbstractButtonPrivate, parent, 0){    Q_D(QAbstractButton);    d->init();}/*!    Destroys the button. */ QAbstractButton::~QAbstractButton(){#ifndef QT_NO_BUTTONGROUP    Q_D(QAbstractButton);    if (d->group)        d->group->removeButton(this);#endif}/*! \internal */QAbstractButton::QAbstractButton(QAbstractButtonPrivate &dd, QWidget *parent)    : QWidget(dd, parent, 0){    Q_D(QAbstractButton);    d->init();}/*!\property QAbstractButton::text\brief the text shown on the buttonIf the button has no text, the text() function will return a an emptystring.If the text contains an ampersand character ('&'), a shortcut isautomatically created for it. The character that follows the '&' willbe used as the shortcut key. Any previous shortcut will beoverwritten, or cleared if no shortcut is defined by the text. See the\l {QShortcut#mnemonic}{QShortcut} documentation for details (todisplay an actual ampersand, use '&&').There is no default text.*/void QAbstractButton::setText(const QString &text){    Q_D(QAbstractButton);    if (d->text == text)        return;    d->text = text;#ifndef QT_NO_SHORTCUT    QKeySequence newMnemonic = QKeySequence::mnemonic(text);    if (!newMnemonic.isEmpty())        setShortcut(newMnemonic);#endif    d->sizeHint = QSize();    update();    updateGeometry();#ifndef QT_NO_ACCESSIBILITY    QAccessible::updateAccessibility(this, 0, QAccessible::NameChanged);#endif}QString QAbstractButton::text() const{    Q_D(const QAbstractButton);    return d->text;}/*!  \property QAbstractButton::icon  \brief the icon shown on the button  The icon's default size is defined by the GUI style, but can be  adjusted by setting the \l iconSize property.*/void QAbstractButton::setIcon(const QIcon &icon){    Q_D(QAbstractButton);    d->icon = icon;    d->sizeHint = QSize();    update();    updateGeometry();}QIcon QAbstractButton::icon() const{    Q_D(const QAbstractButton);    return d->icon;}#ifndef QT_NO_SHORTCUT/*!\property QAbstractButton::shortcut\brief the mnemonic associated with the button*/void QAbstractButton::setShortcut(const QKeySequence &key){    Q_D(QAbstractButton);    if (d->shortcutId != 0)        releaseShortcut(d->shortcutId);    d->shortcut = key;    d->shortcutId = grabShortcut(key);}QKeySequence QAbstractButton::shortcut() const{    Q_D(const QAbstractButton);    return d->shortcut;}#endif // QT_NO_SHORTCUT/*!\property QAbstractButton::checkable\brief whether the button is checkableBy default, the button is not checkable.\sa checked*/void QAbstractButton::setCheckable(bool checkable){    Q_D(QAbstractButton);    if (d->checkable == checkable)        return;    d->checkable = checkable;    d->checked = false;}bool QAbstractButton::isCheckable() const{    Q_D(const QAbstractButton);    return d->checkable;}/*!\property QAbstractButton::checked\brief whether the button is checkedOnly checkable buttons can be checked. By default, the button is unchecked.\sa checkable*/void QAbstractButton::setChecked(bool checked){    Q_D(QAbstractButton);    if (!d->checkable || d->checked == checked) {        if (!d->blockRefresh)            checkStateSet();        return;    }    if (!checked && d->queryCheckedButton() == this) {        // the checked button of an exclusive or autoexclusive group cannot be  unchecked#ifndef QT_NO_BUTTONGROUP        if (d->group ? d->group->d_func()->exclusive : d->autoExclusive)            return;        if (d->group)            d->group->d_func()->detectCheckedButton();#else        if (d->autoExclusive)            return;#endif    }    QPointer<QAbstractButton> guard(this);    d->checked = checked;    if (!d->blockRefresh)        checkStateSet();    d->refresh();    if (guard && checked)        d->notifyChecked();    if (guard)        emit toggled(checked);}bool QAbstractButton::isChecked() const{    Q_D(const QAbstractButton);    return d->checked;}/*!  \property QAbstractButton::down  \brief whether the button is pressed down  If this property is true, the button is pressed down. The signals  pressed() and clicked() are not emitted if you set this property  to true. The default is false.*/void QAbstractButton::setDown(bool down){    Q_D(QAbstractButton);    if (d->down == down)        return;    d->down = down;    d->refresh();    if (d->autoRepeat && d->down)        d->repeatTimer.start(d->autoRepeatDelay, this);    else        d->repeatTimer.stop();}bool QAbstractButton::isDown() const{    Q_D(const QAbstractButton);    return d->down;}/*!\property QAbstractButton::autoRepeat\brief whether autoRepeat is enabledIf autoRepeat is enabled, then the pressed(), released(), and clicked() signals are emitted atregular intervals when the button is down. autoRepeat is off by default.The initial delay and the repetition interval are defined in milliseconds by \lautoRepeatDelay and \l autoRepeatInterval.Note: If a button is pressed down by a shortcut key, then auto-repeat is enabled and timed by thesystem and not by this class. The pressed(), released(), and clicked() signals will be emittedlike in the normal case.*/void QAbstractButton::setAutoRepeat(bool autoRepeat){    Q_D(QAbstractButton);    if (d->autoRepeat == autoRepeat)        return;    d->autoRepeat = autoRepeat;    if (d->autoRepeat && d->down)        d->repeatTimer.start(d->autoRepeatDelay, this);    else        d->repeatTimer.stop();}bool QAbstractButton::autoRepeat() const{    Q_D(const QAbstractButton);    return d->autoRepeat;}/*!    \property QAbstractButton::autoRepeatDelay    \brief the initial delay of auto-repetition    \since 4.2    If \l autoRepeat is enabled, then autoRepeatDelay defines the initial    delay in milliseconds before auto-repetition kicks in.    \sa autoRepeat, autoRepeatInterval*/void QAbstractButton::setAutoRepeatDelay(int autoRepeatDelay){    Q_D(QAbstractButton);    d->autoRepeatDelay = autoRepeatDelay;}int QAbstractButton::autoRepeatDelay() const{    Q_D(const QAbstractButton);    return d->autoRepeatDelay;}/*!    \property QAbstractButton::autoRepeatInterval    \brief the interval of auto-repetition    \since 4.2    If \l autoRepeat is enabled, then autoRepeatInterval defines the    length of the auto-repetition interval in millisecons.    \sa autoRepeat, autoRepeatDelay*/void QAbstractButton::setAutoRepeatInterval(int autoRepeatInterval){    Q_D(QAbstractButton);    d->autoRepeatInterval = autoRepeatInterval;}int QAbstractButton::autoRepeatInterval() const{    Q_D(const QAbstractButton);    return d->autoRepeatInterval;}/*!\property QAbstractButton::autoExclusive\brief whether auto-exclusivity is enabledIf auto-exclusivity is enabled, checkable buttons that belong to thesame parent widget behave as if they were part of the sameexclusive button group. In an exclusive button group, only one buttoncan be checked at any time; checking another button automaticallyunchecks the previously checked one.The property has no effect on buttons that belong to a buttongroup.autoExclusive is off by default, except for radio buttons.\sa QRadioButton*/void QAbstractButton::setAutoExclusive(bool autoExclusive){    Q_D(QAbstractButton);    d->autoExclusive = autoExclusive;}bool QAbstractButton::autoExclusive() const{    Q_D(const QAbstractButton);    return d->autoExclusive;}#ifndef QT_NO_BUTTONGROUP/*!  Returns the group that this button belongs to.  If the button is not a member of any QButtonGroup, this function  returns 0.  \sa QButtonGroup*/QButtonGroup *QAbstractButton::group() const{    Q_D(const QAbstractButton);    return d->group;}#endif // QT_NO_BUTTONGROUP/*!Performs an animated click: the button is pressed immediately, andreleased \a msec milliseconds later (the default is 100 ms).Calling this function again before the button was released will resetthe release timer.All signals associated with a click are emitted as appropriate.This function does nothing if the button is \link setEnabled()disabled. \endlink\sa click()*/void QAbstractButton::animateClick(int msec){    if (!isEnabled())        return;    Q_D(QAbstractButton);    if (d->checkable && focusPolicy() != Qt::NoFocus)        setFocus();    setDown(true);    repaint(); //flush paint event before invoking potentially expensive operation    QApplication::flush();    if (!d->animateTimer.isActive())        d->emitPressed();    d->animateTimer.start(msec, this);}/*!Performs a click.All the usual signals associated with a click are emitted asappropriate. If the button is checkable, the state of the button istoggled.This function does nothing if the button is \link setEnabled()disabled. \endlink\sa animateClick() */void QAbstractButton::click(){    if (!isEnabled())        return;    Q_D(QAbstractButton);    QPointer<QAbstractButton> guard(this);    d->down = true;    d->emitPressed();    if (guard) {        d->down = false;        nextCheckState();        if (guard)            d->emitReleased();

⌨️ 快捷键说明

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