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

📄 qabstractscrollarea.cpp

📁 奇趣公司比较新的qt/emd版本
💻 CPP
📖 第 1 页 / 共 3 页
字号:
    scrollBarContainers[Qt::Horizontal]->setVisible(needh);    scrollBarContainers[Qt::Vertical]->setVisible(needv);    if (q->isRightToLeft())        viewportRect.adjust(right, top, -left, -bottom);    else        viewportRect.adjust(left, top, -right, -bottom);    viewport->setGeometry(QStyle::visualRect(opt.direction, opt.rect, viewportRect)); // resize the viewport last}// ### Fix for 4.4, talk to Bjoern E or Girish.void QAbstractScrollAreaPrivate::scrollBarPolicyChanged(Qt::Orientation, Qt::ScrollBarPolicy) {}/*!    \internal    Creates a new QAbstractScrollAreaPrivate, \a dd with the given \a parent.*/QAbstractScrollArea::QAbstractScrollArea(QAbstractScrollAreaPrivate &dd, QWidget *parent)    :QFrame(dd, parent){    Q_D(QAbstractScrollArea);    d->init();}/*!    Constructs a viewport.    The \a parent arguments is sent to the QWidget constructor.*/QAbstractScrollArea::QAbstractScrollArea(QWidget *parent)    :QFrame(*new QAbstractScrollAreaPrivate, parent){    Q_D(QAbstractScrollArea);    d->init();}/*!  Destroys the viewport. */QAbstractScrollArea::~QAbstractScrollArea(){    Q_D(QAbstractScrollArea);    delete d->viewportFilter;}/*!  \since 4.2  Sets the viewport to be the given \a widget.  The QAbstractScrollArea will take ownership of the given \a widget.  If \a widget is 0, QAbstractScrollArea will assign a new QWidget instance  for the viewport.  \sa viewport()*/void QAbstractScrollArea::setViewport(QWidget *widget){    Q_D(QAbstractScrollArea);    if (widget != d->viewport) {        QWidget *oldViewport = d->viewport;        if (!widget)            widget = new QWidget;        d->viewport = widget;        d->viewport->setParent(this);        d->viewport->setFocusProxy(this);        d->viewport->installEventFilter(d->viewportFilter);        d->layoutChildren();        if (isVisible())            d->viewport->show();        QMetaObject::invokeMethod(this, "setupViewport", Q_ARG(QWidget *, widget));        delete oldViewport;    }}/*!    Returns the viewport widget.    Use the QScrollArea::widget() function to retrieve the contents of    the viewport widget.    \sa QScrollArea::widget()*/QWidget *QAbstractScrollArea::viewport() const{    Q_D(const QAbstractScrollArea);    return d->viewport;}/*!Returns the size of the viewport as if the scroll bars had no validscrolling range.*/// ### still thinking about the nameQSize QAbstractScrollArea::maximumViewportSize() const{    Q_D(const QAbstractScrollArea);    int hsbExt = d->hbar->sizeHint().height();    int vsbExt = d->vbar->sizeHint().width();    int f = 2 * d->frameWidth;    QSize max = size() - QSize(f + d->left + d->right, f + d->top + d->bottom);    if (d->vbarpolicy == Qt::ScrollBarAlwaysOn)        max.rwidth() -= vsbExt;    if (d->hbarpolicy == Qt::ScrollBarAlwaysOn)        max.rheight() -= hsbExt;    return max;}/*!    \property QAbstractScrollArea::verticalScrollBarPolicy    \brief the policy for the vertical scroll bar    The default policy is Qt::ScrollBarAsNeeded.    \sa horizontalScrollBarPolicy*/Qt::ScrollBarPolicy QAbstractScrollArea::verticalScrollBarPolicy() const{    Q_D(const QAbstractScrollArea);    return d->vbarpolicy;}void QAbstractScrollArea::setVerticalScrollBarPolicy(Qt::ScrollBarPolicy policy){    Q_D(QAbstractScrollArea);    const Qt::ScrollBarPolicy oldPolicy = d->vbarpolicy;    d->vbarpolicy = policy;    if (isVisible())        d->layoutChildren();    if (oldPolicy != d->vbarpolicy)        d->scrollBarPolicyChanged(Qt::Vertical, d->vbarpolicy);}/*!  Returns the vertical scroll bar.  \sa verticalScrollBarPolicy, horizontalScrollBar() */QScrollBar *QAbstractScrollArea::verticalScrollBar() const{    Q_D(const QAbstractScrollArea);    return d->vbar;}/*!   \since 4.2   Replaces the existing vertical scroll bar with \a scrollBar, and sets all   the former scroll bar's slider properties on the new scroll bar. The former   scroll bar is then deleted.   QAbstractScrollArea already provides vertical and horizontal scroll bars by   default. You can call this function to replace the default vertical   scroll bar with your own custom scroll bar.   \sa verticalScrollBar(), setHorizontalScrollBar()*/void QAbstractScrollArea::setVerticalScrollBar(QScrollBar *scrollBar){    Q_D(QAbstractScrollArea);    if (!scrollBar) {        qWarning("QAbstractScrollArea::setVerticalScrollBar: Cannot set a null scroll bar");        return;    }    d->replaceScrollBar(scrollBar, Qt::Vertical);}/*!    \property QAbstractScrollArea::horizontalScrollBarPolicy    \brief the policy for the horizontal scroll bar    The default policy is Qt::ScrollBarAsNeeded.    \sa verticalScrollBarPolicy*/Qt::ScrollBarPolicy QAbstractScrollArea::horizontalScrollBarPolicy() const{    Q_D(const QAbstractScrollArea);    return d->hbarpolicy;}void QAbstractScrollArea::setHorizontalScrollBarPolicy(Qt::ScrollBarPolicy policy){    Q_D(QAbstractScrollArea);    const Qt::ScrollBarPolicy oldPolicy = d->hbarpolicy;    d->hbarpolicy = policy;    if (isVisible())        d->layoutChildren();    if (oldPolicy != d->hbarpolicy)        d->scrollBarPolicyChanged(Qt::Horizontal, d->hbarpolicy);}/*!  Returns the horizontal scroll bar.  \sa horizontalScrollBarPolicy, verticalScrollBar() */QScrollBar *QAbstractScrollArea::horizontalScrollBar() const{    Q_D(const QAbstractScrollArea);    return d->hbar;}/*!    \since 4.2    Replaces the existing horizontal scroll bar with \a scrollBar, and sets all    the former scroll bar's slider properties on the new scroll bar. The former    scroll bar is then deleted.    QAbstractScrollArea already provides horizontal and vertical scroll bars by    default. You can call this function to replace the default horizontal    scroll bar with your own custom scroll bar.    \sa horizontalScrollBar(), setVerticalScrollBar()*/void QAbstractScrollArea::setHorizontalScrollBar(QScrollBar *scrollBar){    Q_D(QAbstractScrollArea);    if (!scrollBar) {        qWarning("QAbstractScrollArea::setHorizontalScrollBar: Cannot set a null scroll bar");        return;    }    d->replaceScrollBar(scrollBar, Qt::Horizontal);}/*!    \since 4.2    Returns the widget in the corner between the two scroll bars.    By default, no corner widget is present.*/QWidget *QAbstractScrollArea::cornerWidget() const{    Q_D(const QAbstractScrollArea);    return d->cornerWidget;}/*!    \since 4.2    Sets the widget in the corner between the two scroll bars to be    \a widget.    You will probably also want to set at least one of the scroll bar    modes to \c AlwaysOn.    Passing 0 shows no widget in the corner.    Any previous corner widget is hidden.    You may call setCornerWidget() with the same widget at different    times.    All widgets set here will be deleted by the scroll area when it is    destroyed unless you separately reparent the widget after setting    some other corner widget (or 0).    Any \e newly set widget should have no current parent.    By default, no corner widget is present.    \sa horizontalScrollBarPolicy, horizontalScrollBarPolicy*/void QAbstractScrollArea::setCornerWidget(QWidget *widget){    Q_D(QAbstractScrollArea);    QWidget* oldWidget = d->cornerWidget;    if (oldWidget != widget) {        if (oldWidget)            oldWidget->hide();        d->cornerWidget = widget;        if (widget && widget->parentWidget() != this)            widget->setParent(this);        d->layoutChildren();        if (widget)            widget->show();    } else {        d->cornerWidget = widget;        d->layoutChildren();    }}/*!    \since 4.2    Adds \a widget as a scroll bar widget in the location specified    by \a alignment.    Scroll bar widgets are shown next to the horizontal or vertical    scroll bar, and can be placed on either side of it. If you want    the scroll bar widgets to be always visible, set the    scrollBarPolicy for the corresponding scroll bar to \c AlwaysOn.    \a alignment must be one of Qt::Alignleft and Qt::AlignRight,    which maps to the horizontal scroll bar, or Qt::AlignTop and    Qt::AlignBottom, which maps to the vertical scroll bar.    A scroll bar widget can be removed by either re-parenting the    widget or deleting it. It's also possible to hide a widget with    QWidget::hide()    The scroll bar widget will be resized to fit the scroll bar    geometry for the current style. The following describes the case    for scroll bar widgets on the horizontal scroll bar:    The height of the widget will be set to match the height of the    scroll bar. To control the width of the widget, use    QWidget::setMinimumWidth and QWidget::setMaximumWidth, or    implement QWidget::sizeHint() and set a horizontal size policy.    If you want a square widget, call    QStyle::pixelMetric(QStyle::PM_ScrollBarExtent) and set the    width to this value.    \sa scrollBarWidgets()*/void QAbstractScrollArea::addScrollBarWidget(QWidget *widget, Qt::Alignment alignment){    Q_D(QAbstractScrollArea);    if (widget == 0)        return;    const Qt::Orientation scrollBarOrientation        = ((alignment & Qt::AlignLeft) || (alignment & Qt::AlignRight)) ? Qt::Horizontal : Qt::Vertical;    const QAbstractScrollAreaScrollBarContainer::LogicalPosition position        = ((alignment & Qt::AlignRight) || (alignment & Qt::AlignBottom))          ? QAbstractScrollAreaScrollBarContainer::LogicalRight : QAbstractScrollAreaScrollBarContainer::LogicalLeft;    d->scrollBarContainers[scrollBarOrientation]->addWidget(widget, position);    d->layoutChildren();    if (isHidden() == false)        widget->show();}/*!    \since 4.2    Returns a list of the currently set scroll bar widgets. \a alignment    can be any combination of the four location flags.    \sa addScrollBarWidget()*/QWidgetList QAbstractScrollArea::scrollBarWidgets(Qt::Alignment alignment){    Q_D(QAbstractScrollArea);    QWidgetList list;    if (alignment & Qt::AlignLeft)        list += d->scrollBarContainers[Qt::Horizontal]->widgets(QAbstractScrollAreaScrollBarContainer::LogicalLeft);    if (alignment & Qt::AlignRight)        list += d->scrollBarContainers[Qt::Horizontal]->widgets(QAbstractScrollAreaScrollBarContainer::LogicalRight);    if (alignment & Qt::AlignTop)        list += d->scrollBarContainers[Qt::Vertical]->widgets(QAbstractScrollAreaScrollBarContainer::LogicalLeft);    if (alignment & Qt::AlignBottom)        list += d->scrollBarContainers[Qt::Vertical]->widgets(QAbstractScrollAreaScrollBarContainer::LogicalRight);    return list;}/*!    Sets the margins around the scrolling area to \a left, \a top, \a    right and \a bottom. This is useful for applications such as    spreadsheets with "locked" rows and columns. The marginal space is    is left blank; put widgets in the unused area.    Note that this function is frequently called by QTreeView and    QTableView, so margins must be implemented by QAbstractScrollArea    subclasses. Also, if the subclasses are to be used in item views,    they should not call this function.     By default all margins are zero.*/void QAbstractScrollArea::setViewportMargins(int left, int top, int right, int bottom){    Q_D(QAbstractScrollArea);    d->left = left;    d->top = top;    d->right = right;    d->bottom = bottom;    d->layoutChildren();}/*!    \fn bool QAbstractScrollArea::event(QEvent *event)    \reimp    This is the main event handler for the QAbstractScrollArea widget (\e not    the scrolling area viewport()). The specified \a event is a general event    object that may need to be cast to the appropriate class depending on its    type.    \sa QEvent::type()*/bool QAbstractScrollArea::event(QEvent *e){    Q_D(QAbstractScrollArea);    switch (e->type()) {    case QEvent::AcceptDropsChange:        d->viewport->setAcceptDrops(acceptDrops());        break;    case QEvent::MouseTrackingChange:        d->viewport->setMouseTracking(hasMouseTracking());        break;    case QEvent::Resize:            d->layoutChildren();

⌨️ 快捷键说明

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