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

📄 qstatusbar.cpp

📁 奇趣公司比较新的qt/emd版本
💻 CPP
📖 第 1 页 / 共 2 页
字号:
    \note This function does not delete the widget but \e hides it.    To add the widget again, you must call both the addWidget() and    show() functions.    \sa addWidget(), addPermanentWidget(), clearMessage()*/void QStatusBar::removeWidget(QWidget *widget){    if (!widget)        return;    Q_D(QStatusBar);    bool found = false;    QStatusBarPrivate::SBItem* item;    for (int i=0; i<d->items.size(); ++i) {        item = d->items.at(i);        if (!item)            break;        if (item->w == widget) {            d->items.removeAt(i);            item->w->hide();            delete item;            found = true;            break;        }    }    if (found)        reformat();#if defined(QT_DEBUG)    else        qDebug("QStatusBar::removeWidget(): Widget not found.");#endif}/*!    \property QStatusBar::sizeGripEnabled    \brief whether the QSizeGrip in the bottom-right corner of the    status bar is enabled    The size grip is enabled by default.*/bool QStatusBar::isSizeGripEnabled() const{#ifdef QT_NO_SIZEGRIP    return false;#else    Q_D(const QStatusBar);    return !!d->resizer;#endif}void QStatusBar::setSizeGripEnabled(bool enabled){#ifdef QT_NO_SIZEGRIP    Q_UNUSED(enabled);#else    Q_D(QStatusBar);    if (!enabled != !d->resizer) {        if (enabled) {            d->resizer = new QSizeGrip(this);        } else {            delete d->resizer;            d->resizer = 0;        }        reformat();        if (d->resizer && isVisible())            d->resizer->show();    }#endif}/*!    Changes the status bar's appearance to account for item changes.    Special subclasses may need this function, but geometry management    will usually take care of any necessary rearrangements.*/void QStatusBar::reformat(){    Q_D(QStatusBar);    if (d->box)        delete d->box;    QBoxLayout *vbox;#ifndef QT_NO_SIZEGRIP    if (d->resizer) {        d->box = new QHBoxLayout(this);        d->box->setMargin(0);        vbox = new QVBoxLayout;        d->box->addLayout(vbox);    } else#endif    {        vbox = d->box = new QVBoxLayout(this);        d->box->setMargin(0);    }    vbox->addSpacing(3);    QBoxLayout* l = new QHBoxLayout;    vbox->addLayout(l);    l->addSpacing(2);    l->setSpacing(6);    int maxH = fontMetrics().height();    int i;    QStatusBarPrivate::SBItem* item;    for (i=0,item=0; i<d->items.size(); ++i) {        item = d->items.at(i);        if (!item || item->p)            break;        l->addWidget(item->w, item->s);        int itemH = qMin(qSmartMinSize(item->w).height(), item->w->maximumHeight());        maxH = qMax(maxH, itemH);    }    l->addStretch(0);    for (item=0; i<d->items.size(); ++i) {        item = d->items.at(i);        if (!item)            break;        l->addWidget(item->w, item->s);        int itemH = qMin(qSmartMinSize(item->w).height(), item->w->maximumHeight());        maxH = qMax(maxH, itemH);    }#ifndef QT_NO_SIZEGRIP    if (d->resizer) {        maxH = qMax(maxH, d->resizer->sizeHint().height());        d->box->addSpacing(1);        d->box->addWidget(d->resizer, 0, Qt::AlignBottom);    }#endif    l->addStrut(maxH);    d->savedStrut = maxH;    vbox->addSpacing(2);    d->box->activate();    repaint();}/*!    Hides the normal status indications and displays the given \a    message for the specified \a timeout milli-seconds (if non-zero),    or until clearMessage() or another showMessage() is called,    whichever occurs first.    \sa messageChanged(), currentMessage(), clearMessage()*/void QStatusBar::showMessage(const QString &message, int timeout){    Q_D(QStatusBar);    if (d->tempItem == message)        return;    d->tempItem = message;    if (timeout > 0) {        if (!d->timer) {            d->timer = new QTimer(this);            connect(d->timer, SIGNAL(timeout()), this, SLOT(clearMessage()));        }        d->timer->start(timeout);    } else if (d->timer) {        delete d->timer;        d->timer = 0;    }    hideOrShow();}/*!    Removes any temporary message being shown.    \sa currentMessage(), showMessage(), removeWidget()*/void QStatusBar::clearMessage(){    Q_D(QStatusBar);    if (d->tempItem.isEmpty())        return;    if (d->timer) {        delete d->timer;        d->timer = 0;    }    d->tempItem.clear();    hideOrShow();}/*!    Returns the temporary message currently shown,    or an empty string if there is no such message.    \sa showMessage()*/QString QStatusBar::currentMessage() const{    Q_D(const QStatusBar);    return d->tempItem;}/*!    \fn void QStatusBar::message(const QString &message, int timeout)    Use the showMessage() function instead.*//*!    \fn void QStatusBar::clear()    Use the clearMessage() function instead.*//*!    \fn QStatusBar::messageChanged(const QString &message)    This signal is emitted whenever the temporary status message    changes. The new temporary message is passed in the \a message    parameter which is a null-string when the message has been    removed.    \sa showMessage(), clearMessage()*//*!    Ensures that the right widgets are visible.    Used by the showMessage() and clearMessage() functions.*/void QStatusBar::hideOrShow(){    Q_D(QStatusBar);    bool haveMessage = !d->tempItem.isEmpty();    QStatusBarPrivate::SBItem* item = 0;    for (int i=0; i<d->items.size(); ++i) {        item = d->items.at(i);        if (!item || item->p)            break;        if (haveMessage)            item->w->hide();        else            item->w->show();    }    emit messageChanged(d->tempItem);    repaint();}/*!    \reimp    \fn void QStatusBar::paintEvent(QPaintEvent *event)    Shows the temporary message, if appropriate, in response to the    paint \a event.*/void QStatusBar::paintEvent(QPaintEvent *){    Q_D(QStatusBar);    bool haveMessage = !d->tempItem.isEmpty();    QPainter p(this);    QStatusBarPrivate::SBItem* item = 0;    bool rtl = layoutDirection() == Qt::RightToLeft;    int left = 6;    int right = width() - 12;#ifndef QT_NO_SIZEGRIP    if (d->resizer && d->resizer->isVisible()) {        if (rtl)            left = d->resizer->x() + d->resizer->width();        else            right = d->resizer->x();    }#endif    for (int i=0; i<d->items.size(); ++i) {        item = d->items.at(i);        if (!item)            break;        if (!haveMessage || item->p)            if (item->w->isVisible()) {                if (item->p) {                    if (rtl)                        left = qMax(left, item->w->x() + item->w->width() + 2);                    else                        right = qMin(right, item->w->x()-1);                }                QStyleOption opt(0);                opt.rect.setRect(item->w->x() - 2, item->w->y() - 1,                                 item->w->width() + 4, item->w->height() + 2);                opt.palette = palette();                opt.state = QStyle::State_None;                style()->drawPrimitive(QStyle::PE_FrameStatusBar, &opt, &p, item->w);            }    }    if (haveMessage) {        p.setPen(palette().foreground().color());        p.drawText(left, 0, right-left, height(), Qt::AlignLeading | Qt::AlignVCenter | Qt::TextSingleLine, d->tempItem);    }}/*!    \reimp*/void QStatusBar::resizeEvent(QResizeEvent * e){    QWidget::resizeEvent(e);}/*!    \reimp*/bool QStatusBar::event(QEvent *e){    Q_D(QStatusBar);    if (e->type() == QEvent::LayoutRequest#ifdef QT3_SUPPORT        || e->type() == QEvent::LayoutHint#endif        ) {        // Calculate new strut height and call reformat() if it has changed        int maxH = fontMetrics().height();        QStatusBarPrivate::SBItem* item = 0;        for (int i=0; i<d->items.size(); ++i) {            item = d->items.at(i);            if (!item)                break;            int itemH = qMin(qSmartMinSize(item->w).height(), item->w->maximumHeight());            maxH = qMax(maxH, itemH);        }#ifndef QT_NO_SIZEGRIP        if (d->resizer)            maxH = qMax(maxH, d->resizer->sizeHint().height());#endif        if (maxH != d->savedStrut)            reformat();        else            update();    }    if (e->type() == QEvent::ChildRemoved) {        QStatusBarPrivate::SBItem* item = 0;        for (int i=0; i<d->items.size(); ++i) {            item = d->items.at(i);            if (!item)                break;            if (item->w == ((QChildEvent*)e)->child()) {                d->items.removeAt(i);                delete item;            }        }    }    return QWidget::event(e);}#endif

⌨️ 快捷键说明

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