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

📄 qprogressbar.cpp

📁 奇趣公司比较新的qt/emd版本
💻 CPP
📖 第 1 页 / 共 2 页
字号:
    \property QProgressBar::value    \brief the progress bar's current value    Attempting to change the current value to one outside    the minimum-maximum range has no effect on the current value.*/void QProgressBar::setValue(int value){    Q_D(QProgressBar);    if (d->value == value            || ((value > d->maximum || value < d->minimum)                && (d->maximum != 0 || d->minimum != 0)))        return;    d->value = value;    emit valueChanged(value);#ifndef QT_NO_ACCESSIBILITY    QAccessible::updateAccessibility(this, 0, QAccessible::ValueChanged);#endif    if (d->repaintRequired())        repaint();}int QProgressBar::value() const{    return d_func()->value;}/*!    Sets the progress bar's minimum and maximum values to \a minimum and    \a maximum respectively.    If \a maximum is smaller than \a minimum, \a minimum becomes the only    legal value.    If the current value falls outside the new range, the progress bar is reset    with reset().    \sa minimum maximum*/void QProgressBar::setRange(int minimum, int maximum){    Q_D(QProgressBar);    d->minimum = minimum;    d->maximum = qMax(minimum, maximum);    if ( d->value <(d->minimum-1) || d->value > d->maximum)        reset();}/*!    \property QProgressBar::textVisible    \brief whether the current completed percentage should be displayed    \sa textDirection*/void QProgressBar::setTextVisible(bool visible){    Q_D(QProgressBar);    if (d->textVisible != visible) {        d->textVisible = visible;        repaint();    }}bool QProgressBar::isTextVisible() const{    return d_func()->textVisible;}/*!    \property QProgressBar::alignment    \brief the alignment of the progress bar*/void QProgressBar::setAlignment(Qt::Alignment alignment){    if (d_func()->alignment != alignment) {        d_func()->alignment = alignment;        repaint();    }}Qt::Alignment QProgressBar::alignment() const{    return d_func()->alignment;}/*!    \reimp*/void QProgressBar::paintEvent(QPaintEvent *){    QStylePainter paint(this);    QStyleOptionProgressBarV2 opt;    initStyleOption(&opt);    paint.drawControl(QStyle::CE_ProgressBar, opt);    d_func()->lastPaintedValue = d_func()->value;}/*!    \reimp*/QSize QProgressBar::sizeHint() const{    ensurePolished();    QFontMetrics fm = fontMetrics();    QStyleOptionProgressBarV2 opt;    initStyleOption(&opt);    int cw = style()->pixelMetric(QStyle::PM_ProgressBarChunkWidth, &opt, this);    QSize size = QSize(cw * 7 + fm.width(QLatin1Char('0')) * 4, fm.height() + 8);    if (opt.orientation == Qt::Vertical)        size.transpose();    return style()->sizeFromContents(QStyle::CT_ProgressBar, &opt, size, this);}/*!    \reimp*/QSize QProgressBar::minimumSizeHint() const{    QSize size;    if (orientation() == Qt::Horizontal)        size = QSize(sizeHint().width(), fontMetrics().height() + 2);    else        size = QSize(fontMetrics().height() + 2, sizeHint().height());    return size;}/*!    \property QProgressBar::text    \brief the descriptive text shown with the progress bar    The text returned is the same as the text displayed in the center    (or in some styles, to the left) of the progress bar.    The progress shown in the text may be smaller than the minimum value,    indicating that the progress bar is in the "reset" state before any    progress is set.    In the default implementation, the text either contains a percentage    value that indicates the progress so far, or it is blank because the    progress bar is in the reset state.*/QString QProgressBar::text() const{    Q_D(const QProgressBar);    if (d->maximum == 0 || d->value < d->minimum            || (d->value == INT_MIN && d->minimum == INT_MIN))        return QString();    qint64 totalSteps = qint64(d->maximum) - qint64(d->minimum);    QString result = d->format;    result.replace(QLatin1String("%m"), QString::fromLatin1("%1").arg(totalSteps));    result.replace(QLatin1String("%v"), QString::fromLatin1("%1").arg(d->value));    // If max and min are equal and we get this far, it means that the    // progress bar has one step and that we are on that step. Return    // 100% here in order to avoid division by zero further down.    if (totalSteps == 0) {        result.replace(QLatin1String("%p"), QString::fromLatin1("%1").arg(100));        return result;    }    int progress = int(((qreal(d->value) - qreal(d->minimum)) * 100.0) / totalSteps);    result.replace(QLatin1String("%p"), QString::fromLatin1("%1").arg(progress));    return result;}/*!    \since 4.1    \property QProgressBar::orientation    \brief the orientation of the progress bar    The orientation must be \l Qt::Horizontal (the default) or \l    Qt::Vertical.    \sa invertedAppearance, textDirection*/void QProgressBar::setOrientation(Qt::Orientation orientation){    Q_D(QProgressBar);    if (d->orientation == orientation)        return;    d->orientation = orientation;    if (!testAttribute(Qt::WA_WState_OwnSizePolicy)) {        QSizePolicy sp = sizePolicy();        sp.transpose();        setSizePolicy(sp);        setAttribute(Qt::WA_WState_OwnSizePolicy, false);    }    d->resetLayoutItemMargins();    update();    updateGeometry();}Qt::Orientation QProgressBar::orientation() const{    Q_D(const QProgressBar);    return d->orientation;}/*!    \since 4.1    \property QProgressBar::invertedAppearance    \brief whether or not a progress bar shows its progress inverted    If this property is false, the progress bar grows in the other    direction (e.g. from right to left). By default, the progress bar    is not inverted.    \sa orientation, layoutDirection*/void QProgressBar::setInvertedAppearance(bool invert){    Q_D(QProgressBar);    d->invertedAppearance = invert;    update();}bool QProgressBar::invertedAppearance(){    Q_D(QProgressBar);    return d->invertedAppearance;}/*!    \since 4.1    \property QProgressBar::textDirection    \brief the reading direction of the \l text for vertical progress bars    This property has no impact on horizontal progress bars.    By default, the reading direction is QProgressBar::TopToBottom.    \sa orientation, textVisible*/void QProgressBar::setTextDirection(QProgressBar::Direction textDirection){    Q_D(QProgressBar);    d->textDirection = textDirection;    update();}QProgressBar::Direction QProgressBar::textDirection(){    Q_D(QProgressBar);    return d->textDirection;}/*! \reimp */bool QProgressBar::event(QEvent *e){    Q_D(QProgressBar);    if (e->type() == QEvent::StyleChange#ifdef Q_WS_MAC            || e->type() == QEvent::MacSizeChange#endif            )        d->resetLayoutItemMargins();    return QWidget::event(e);}/*!    \since 4.2    \property QProgressBar::format    \brief the string used to generate the current text    %p - is replaced by the percentage completed.    %v - is replaced by the current value.    %m - is replaced by the total number of steps.    The default value is "%p%".    \sa text()*/void QProgressBar::setFormat(const QString &format){    Q_D(QProgressBar);    if (d->format == format)        return;    d->format = format;    update();}QString QProgressBar::format() const{    Q_D(const QProgressBar);    return d->format;}#endif // QT_NO_PROGRESSBAR

⌨️ 快捷键说明

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