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

📄 qsplitter.cpp

📁 奇趣公司比较新的qt/emd版本
💻 CPP
📖 第 1 页 / 共 4 页
字号:
            d->setGeo(sls, poss[wid], ws[wid], true);    }    d->storeSizes();    emit splitterMoved(pos, index);}/*!    Returns the valid range of the splitter with index \a index in    *\a{min} and *\a{max} if \a min and \a max are not 0.*/void QSplitter::getRange(int index, int *min, int *max) const{    Q_D(const QSplitter);    d->getRange(index, min, 0, 0, max);}/*!    Returns the closest legal position to \a pos of the widget with index    \a index.    For right-to-left languages such as Arabic and Hebrew, the layout    of horizontal splitters is reversed. Positions are then measured    from the right edge of the widget.    \sa getRange()*/int QSplitter::closestLegalPosition(int pos, int index){    Q_D(QSplitter);    int x, i, n, u;    return d->adjustPos(pos, index, &u, &n, &i, &x);}/*!    \property QSplitter::opaqueResize    \brief whether resizing is opaque    Opaque resizing is on by default.*/bool QSplitter::opaqueResize() const{    Q_D(const QSplitter);    return d->opaque;}void QSplitter::setOpaqueResize(bool on){    Q_D(QSplitter);    d->opaque = on;}#ifdef QT3_SUPPORT/*!    \fn void QSplitter::moveToFirst(QWidget *widget)    Use insertWidget(0, \a widget) instead.*//*!    \fn void QSplitter::moveToLast(QWidget *widget)    Use addWidget(\a widget) instead.*//*!    \fn void QSplitter::setResizeMode(QWidget *widget, ResizeMode mode)    Use setStretchFactor() instead.    \oldcode        splitter->setResizeMode(firstChild, QSplitter::KeepSize);        splitter->setResizeMode(secondChild, QSplitter::Stretch);    \newcode        splitter->setStretchFactor(splitter->indexOf(firstChild), 0);        splitter->setStretchFactor(splitter->indexOf(secondChild), 1);    \endcode*//*!    \enum QSplitter::ResizeMode    \compat    This enum describes the different resizing behaviors child    widgets can have:    \value Auto   The widget will be resized according to the stretch factors set in its sizePolicy().    \value Stretch  The widget will be resized when the splitter itself is resized.    \value KeepSize  QSplitter will try to keep the widget's size unchanged.    \value FollowSizeHint  QSplitter will resize the widget when the widget's size hint changes.    Use setStretchFactor() instead.*//*!    \fn void QSplitter::setCollapsible(QWidget *widget, bool collapsible)    Use setCollapsible(indexOf(\a widget, \a collapsible)) instead.*//*!    \fn void QSplitter::setMargin(int margin)    Sets the width of the margin around the contents of the widget to \a margin.        Use QWidget::setContentsMargins() instead.    \sa margin(), QWidget::setContentsMargins()*//*!    \fn int QSplitter::margin() const    Returns the with of the the margin around the contents of the widget.        Use QWidget::getContentsMargins() instead.    \sa setMargin(), QWidget::getContentsMargins()*/#endif/*!    \reimp*/QSize QSplitter::sizeHint() const{    Q_D(const QSplitter);    ensurePolished();    int l = 0;    int t = 0;    QObjectList childList = children();    for (int i = 0; i < childList.size(); ++i) {        if (QWidget *w = qobject_cast<QWidget *>(childList.at(i))) {            if (w->isHidden())                continue;            QSize s = w->sizeHint();            if (s.isValid()) {                l += d->pick(s);                t = qMax(t, d->trans(s));            }        }    }    return orientation() == Qt::Horizontal ? QSize(l, t) : QSize(t, l);}/*!    \reimp*/QSize QSplitter::minimumSizeHint() const{    Q_D(const QSplitter);    ensurePolished();    int l = 0;    int t = 0;    for (int i = 0; i < d->list.size(); ++i) {        QSplitterLayoutStruct *s = d->list.at(i);        if (!s || !s->widget)            continue;        if (s->widget->isHidden())            continue;        QSize widgetSize = qSmartMinSize(s->widget);        if (widgetSize.isValid()) {            l += d->pick(widgetSize);            t = qMax(t, d->trans(widgetSize));        }        if (!s->handle || s->handle->isHidden())            continue;        QSize splitterSize = s->handle->sizeHint();        if (splitterSize.isValid()) {            l += d->pick(splitterSize);            t = qMax(t, d->trans(splitterSize));        }    }    return orientation() == Qt::Horizontal ? QSize(l, t) : QSize(t, l);}/*!    Returns a list of the size parameters of all the widgets in this    splitter.    If the splitter's orientation is horizontal, the list is a list of    widget widths; if the orientation is vertical, the list is a list    of widget heights.    Giving the values to another splitter's setSizes() function will    produce a splitter with the same layout as this one.    Note that invisible widgets have a size of 0.    The easiest way to iterate over the list is to use the Java-style iterators.    \quotefromfile snippets/splitter/splitter.cpp    \skipto   QListIterator<int>    \printuntil processSize(it.next());    \sa setSizes()*/QList<int> QSplitter::sizes() const{    Q_D(const QSplitter);    ensurePolished();    QList<int> list;    for (int i = 0; i < d->list.size(); ++i) {        QSplitterLayoutStruct *s = d->list.at(i);        list.append(d->pick(s->rect.size()));    }    return list;}/*!    Sets the size parameters to the values given in the \a list. If    the splitter is horizontal, the values set the widths of each    widget going from left to right. If the splitter is vertical, the    values set the heights of each widget going from top to bottom.    Extra values in the \a list are ignored.    If \a list contains too few values, the result is undefined but    the program will still be well-behaved.    The values in \a list should be the height or width (depending on    orientation()) that the widgets should be resized to. If you specify    a size of 0, the widget will be invisible.    \sa sizes()*/void QSplitter::setSizes(const QList<int> &list){    Q_D(QSplitter);    int j = 0;    for (int i = 0; i < d->list.size(); ++i) {        QSplitterLayoutStruct *s = d->list.at(i);        s->collapsed = false;        s->sizer = qMax(list.value(j++), 0);        int smartMinSize = d->pick(qSmartMinSize(s->widget));        // Make sure that we reset the collapsed state.        if (s->sizer == 0) {            if (d->collapsible(s) && smartMinSize > 0) {                s->collapsed = true;            } else {                s->sizer = smartMinSize;            }        } else {            if (s->sizer < smartMinSize)                s->sizer = smartMinSize;        }    }    d->doResize();}/*!    \property QSplitter::handleWidth    \brief the width of the splitter handles*/int QSplitter::handleWidth() const{    Q_D(const QSplitter);    if (d->handleWidth > 0) {        return d->handleWidth;    } else {        return style()->pixelMetric(QStyle::PM_SplitterWidth, 0, this);    }}void QSplitter::setHandleWidth(int width){    Q_D(QSplitter);    d->handleWidth = width;    d->updateHandles();}/*!    \reimp*/void QSplitter::changeEvent(QEvent *ev){    Q_D(QSplitter);    if(ev->type() == QEvent::StyleChange)        d->updateHandles();    QFrame::changeEvent(ev);}static const qint32 SplitterMagic = 0xff;/*!    Saves the state of the splitter's layout.    Typically this is used in conjunction with QSettings to remember the size    for a future session. A version number is stored as part of the data.    Here is an example:    \quotefromfile snippets/splitter/splitter.cpp    \skipto SAVE    \skipto QSettings    \printuntil saveState()    \sa restoreState()*/QByteArray QSplitter::saveState() const{    int version = 0;    QByteArray data;    QDataStream stream(&data, QIODevice::WriteOnly);    stream << qint32(SplitterMagic);    stream << qint32(version);    stream << sizes();    stream << childrenCollapsible();    stream << qint32(handleWidth());    stream << opaqueResize();    stream << qint32(orientation());    return data;}/*!    Restores the splitter's layout to the \a state specified.    Returns true if the state is restored; otherwise returns false.    Typically this is used in conjunction with QSettings to restore the size    from a past session. Here is an example:    Restore the splitters's state:    \quotefromfile snippets/splitter/splitter.cpp    \skipto RESTORE    \skipto QSettings    \printuntil restoreState(    A failure to restore the splitter's layout may result from either    invalid or out-of-date data in the supplied byte array.    \sa saveState()*/bool QSplitter::restoreState(const QByteArray &state){    Q_D(QSplitter);    int version = 0;    QByteArray sd = state;    QDataStream stream(&sd, QIODevice::ReadOnly);    QList<int> list;    bool b;    qint32 i;    qint32 marker;    qint32 v;    stream >> marker;    stream >> v;    if (marker != SplitterMagic || v != version)        return false;    stream >> list;    setSizes(list);    stream >> b;    setChildrenCollapsible(b);    stream >> i;    setHandleWidth(i);    stream >> b;    setOpaqueResize(b);    stream >> i;    setOrientation(Qt::Orientation(i));    d->doResize();    return true;}/*!    Updates the size policy of the widget at position \a index to    have a stretch factor of \a stretch.    This function is provided for convenience. It is equivalent to    \code        QWidget *widget = splitter->widget(index);        QSizePolicy policy = widget->sizePolicy();        policy.setHorizontalStretch(stretch);        policy.setVerticalStretch(stretch);        widget->setSizePolicy(policy);    \endcode    \sa setSizes(), widget()*/void QSplitter::setStretchFactor(int index, int stretch){    Q_D(QSplitter);    if (index <= -1 || index >= d->list.count())        return;    QWidget *widget = d->list.at(index)->widget;    QSizePolicy sp = widget->sizePolicy();    sp.setHorizontalStretch(stretch);    sp.setVerticalStretch(stretch);    widget->setSizePolicy(sp);}//#ifdef QT3_SUPPORT#ifndef QT_NO_TEXTSTREAM/*!    \relates QSplitter    \obsolete    Use \a ts << \a{splitter}.saveState() instead.*/QTextStream& operator<<(QTextStream& ts, const QSplitter& splitter){    ts << splitter.saveState() << endl;    return ts;}/*!    \relates QSplitter    \obsolete    Use \a ts >> \a{splitter}.restoreState() instead.*/QTextStream& operator>>(QTextStream& ts, QSplitter& splitter){    QString line = ts.readLine();    line = line.simplified();    line.replace(QLatin1Char(' '), QString());    line = line.toUpper();    splitter.restoreState(line.toAscii());    return ts;}#endif // QT_NO_TEXTSTREAM//#endif // QT3_SUPPORT#endif // QT_NO_SPLITTER

⌨️ 快捷键说明

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