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

📄 qabstractbutton.cpp

📁 qt-x11-opensource-src-4.1.4.tar.gz源码
💻 CPP
📖 第 1 页 / 共 3 页
字号:
            continue;        b->setFocusPolicy((Qt::FocusPolicy) ((b == q || !q->isCheckable())                                         ? (b->focusPolicy() | Qt::TabFocus)                                         :  (b->focusPolicy() & ~Qt::TabFocus)));    }}void QAbstractButtonPrivate::init(){    Q_Q(QAbstractButton);    q->setFocusPolicy(Qt::FocusPolicy(q->style()->styleHint(QStyle::SH_Button_FocusPolicy)));    q->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);}void QAbstractButtonPrivate::refresh(){    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;    QPointer<QAbstractButton> guard(q);    q->nextCheckState();    if (!guard)        return;    blockRefresh = false;    refresh();    q->repaint(); //flush paint event before invoking potentially expensive operation    QApplication::flush();    emit q->released();    if (guard)        emit q->clicked(checked);#ifndef QT_NO_BUTTONGROUP    if (guard && group) {        emit group->buttonClicked(group->id(q));        emit group->buttonClicked(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 buttonThis property will return a an empty string if the button has no text.If the text contains an ampersand character (\&), a mnemonic isautomatically created for it. The character that follows the '\&' will beused as the shortcut key. Any previous mnemonic will be overwritten,or cleared if no mnemonic is defined by the text.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    if (d->shortcutId) {        releaseShortcut(d->shortcutId);        d->shortcutId = 0;    }    QKeySequence newMnemonic = QKeySequence::mnemonic(text);    if (!newMnemonic.isEmpty())        d->shortcutId = grabShortcut(newMnemonic);#endif    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;    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)#else        if (d->autoExclusive)#endif            return;    }    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(AUTO_REPEAT_DELAY, 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 clicked() signal is emitted atregular intervals when the button is down. This property has noeffect on toggle buttons. autoRepeat is off by default.*/void QAbstractButton::setAutoRepeat(bool autoRepeat){    Q_D(QAbstractButton);    if (d->autoRepeat == autoRepeat)        return;    d->autoRepeat = autoRepeat;    if (d->autoRepeat && d->down)        d->repeatTimer.start(AUTO_REPEAT_DELAY, this);    else        d->repeatTimer.stop();}bool QAbstractButton::autoRepeat() const{    Q_D(const QAbstractButton);    return d->autoRepeat;}/*!\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 and released\a msec milliseconds later (the default is 100 msecs).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();    emit pressed();    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;    emit pressed();    if (guard) {        d->down = false;        nextCheckState();        if (guard)            emit released();        if (guard)            emit clicked(d->checked);#ifndef QT_NO_BUTTONGROUP        if (guard && d->group)            emit d->group->buttonClicked(this);#endif    }}/*! \fn void QAbstractButton::toggle()    Toggles the state of a checkable button.     \sa checked*/void QAbstractButton::toggle(){    Q_D(QAbstractButton);    setChecked(!d->checked);}/*! This virtual handler is called when setChecked() was called,unless it was called from within nextCheckState(). It allowssubclasses to reset their intermediate button states.\sa nextCheckState() */void QAbstractButton::checkStateSet(){}/*! This virtual handler is called when a button is clicked. Thedefault implementation calls setChecked(!isChecked()) if the buttonisCheckable().  It allows subclasses to implement intermediate buttonstates.\sa checkStateSet()*/void QAbstractButton::nextCheckState(){

⌨️ 快捷键说明

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