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

📄 qgraphicsview.cpp

📁 奇趣公司比较新的qt/emd版本
💻 CPP
📖 第 1 页 / 共 5 页
字号:
    }    return QAbstractScrollArea::sizeHint();}/*!    \property QGraphicsView::renderHints    \brief the default render hints for the view    These hints are    used to initialize QPainter before each visible item is drawn. QPainter    uses render hints to toggle rendering features such as antialiasing and    smooth pixmap transformation.    QPainter::TextAntialiasing is enabled by default.    Example:    \code        QGraphicsScene scene;        scene.addRect(QRectF(-10, -10, 20, 20));        QGraphicsView view(&scene);        view.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);        view.show();    \endcode*/QPainter::RenderHints QGraphicsView::renderHints() const{    Q_D(const QGraphicsView);    return d->renderHints;}void QGraphicsView::setRenderHints(QPainter::RenderHints hints){    Q_D(QGraphicsView);    if (hints == d->renderHints)        return;    d->renderHints = hints;    viewport()->update();}/*!    If \a enabled is true, the render hint \a hint is enabled; otherwise it    is disabled.    \sa renderHints*/void QGraphicsView::setRenderHint(QPainter::RenderHint hint, bool enabled){    Q_D(QGraphicsView);    QPainter::RenderHints oldHints = d->renderHints;    if (enabled)        d->renderHints |= hint;    else        d->renderHints &= ~hint;    if (oldHints != d->renderHints)        viewport()->update();}/*!    \property QGraphicsView::alignment    \brief the alignment of the scene in the view when the whole    scene is visible.    If the whole scene is visible in the view, (i.e., there are no visible    scroll bars,) the view's alignment will decide where the scene will be    rendered in the view. For example, if the alignment is Qt::AlignCenter,    which is default, the scene will be centered in the view, and if the    alignment is (Qt::AlignLeft | Qt::AlignTop), the scene will be rendered in    the top-left corner of the view.*/Qt::Alignment QGraphicsView::alignment() const{    Q_D(const QGraphicsView);    return d->alignment;}void QGraphicsView::setAlignment(Qt::Alignment alignment){    Q_D(QGraphicsView);    if (d->alignment != alignment) {        d->alignment = alignment;        d->recalculateContentSize();    }}/*!    \property QGraphicsView::transformationAnchor    \brief how the view should position the scene during transformations.    QGraphicsView uses this property to decide how to position the scene in    the viewport when the transformation matrix changes, and the coordinate    system of the view is transformed. The default behavior, AnchorViewCenter,    ensures that the scene point at the center of the view remains unchanged    during transformations (e.g., when rotating, the scene will appear to    rotate around the center of the view).    Note that the effect of this property is noticeable when only a part of the    scene is visible (i.e., when there are scroll bars). Otherwise, if the    whole scene fits in the view, QGraphicsScene uses the view \l alignment to    position the scene in the view.    \sa alignment, resizeAnchor*/QGraphicsView::ViewportAnchor QGraphicsView::transformationAnchor() const{    Q_D(const QGraphicsView);    return d->transformationAnchor;}void QGraphicsView::setTransformationAnchor(ViewportAnchor anchor){    Q_D(QGraphicsView);    d->transformationAnchor = anchor;}/*!    \property QGraphicsView::resizeAnchor    \brief how the view should position the scene when the view is resized.    QGraphicsView uses this property to decide how to position the scene in    the viewport when the viewport widget's size changes. The default    behavior, NoAnchor, leaves the scene's position unchanged during a resize;    the top-left corner of the view will appear to be anchored while resizing.    Note that the effect of this property is noticeable when only a part of the    scene is visible (i.e., when there are scroll bars). Otherwise, if the    whole scene fits in the view, QGraphicsScene uses the view \l alignment to    position the scene in the view.    \sa alignment, transformationAnchor, Qt::WNorthWestGravity*/QGraphicsView::ViewportAnchor QGraphicsView::resizeAnchor() const{    Q_D(const QGraphicsView);    return d->resizeAnchor;}void QGraphicsView::setResizeAnchor(ViewportAnchor anchor){    Q_D(QGraphicsView);    d->resizeAnchor = anchor;}/*!    \property QGraphicsView::viewportUpdateMode    \brief how the viewport should update its contents.    \since 4.3    QGraphicsView uses this property to decide how to update areas of the    scene that have been reexposed or changed. Usually you do not need to    modify this property, but there are some cases where doing so can improve    rendering performance. See the ViewportUpdateMode documentation for    specific details.    The default value is MinimalViewportUpdate, where QGraphicsView will    update as small an area of the viewport as possible when the contents    change.    \sa ViewportUpdateMode, cacheMode*/QGraphicsView::ViewportUpdateMode QGraphicsView::viewportUpdateMode() const{    Q_D(const QGraphicsView);    return d->viewportUpdateMode;}void QGraphicsView::setViewportUpdateMode(ViewportUpdateMode mode){    Q_D(QGraphicsView);    d->viewportUpdateMode = mode;}/*!    \property QGraphicsView::optimizationFlags    \brief flags that can be used to tune QGraphicsView's performance.    \since 4.3    QGraphicsView uses clipping, extra bounding rect adjustments, and certain    other aids to improve rendering quality and performance for the common    case graphics scene. However, depending on the target platform, the scene,    and the viewport in use, some of these operations can degrade performance.    The effect varies from flag to flag; see the OptimizationFlags    documentation for details.    By default, no optimization flags are enabled.    \sa setOptimizationFlag()*/QGraphicsView::OptimizationFlags QGraphicsView::optimizationFlags() const{    Q_D(const QGraphicsView);    return d->optimizationFlags;}void QGraphicsView::setOptimizationFlags(OptimizationFlags flags){    Q_D(QGraphicsView);    d->optimizationFlags = flags;}/*!    Enables \a flag if \a enabled is true; otherwise disables \a flag.    \sa optimizationFlags*/void QGraphicsView::setOptimizationFlag(OptimizationFlag flag, bool enabled){    Q_D(QGraphicsView);    if (enabled)        d->optimizationFlags |= flag;    else        d->optimizationFlags &= ~flag;}/*!    \property QGraphicsView::dragMode    \brief the behavior for dragging the mouse over the scene while    the left mouse button is pressed.    This property defines what should happen when the user clicks on the scene    background and drags the mouse (e.g., scrolling the viewport contents    using a pointing hand cursor, or selecting multiple items with a rubber    band). The default value, NoDrag, does nothing.    This behavior only affects mouse clicks that are not handled by any item.    You can define a custom behavior by creating a subclass of QGraphicsView    and reimplementing mouseMoveEvent().*/QGraphicsView::DragMode QGraphicsView::dragMode() const{    Q_D(const QGraphicsView);    return d->dragMode;}void QGraphicsView::setDragMode(DragMode mode){    Q_D(QGraphicsView);    if (d->dragMode == mode)        return;#ifndef QT_NO_CURSOR    if (d->dragMode == ScrollHandDrag)        viewport()->unsetCursor();#endif    d->dragMode = mode;#ifndef QT_NO_CURSOR    if (d->dragMode == ScrollHandDrag) {        // Forget the stored viewport cursor when we enter scroll hand drag mode.        d->hasStoredOriginalCursor = false;        viewport()->setCursor(Qt::OpenHandCursor);    }#endif}#ifndef QT_NO_RUBBERBAND/*!    \property QGraphicsView::rubberBandSelectionMode    \brief the behavior for selecting items with a rubber band selection rectangle.    \since 4.3    This property defines how items are selected when using the RubberBandDrag    drag mode.    The default value is Qt::IntersectsItemShape; all items whose shape    intersects with or is contained by the rubber band are selected.    \sa dragMode, items()*/Qt::ItemSelectionMode QGraphicsView::rubberBandSelectionMode() const{    Q_D(const QGraphicsView);    return d->rubberBandSelectionMode;}void QGraphicsView::setRubberBandSelectionMode(Qt::ItemSelectionMode mode){    Q_D(QGraphicsView);    d->rubberBandSelectionMode = mode;}#endif/*!    \property QGraphicsView::cacheMode    \brief which parts of the view are cached    QGraphicsView can cache pre-rendered content in a QPixmap, which is then    drawn onto the viewport. The purpose of such caching is to speed up the    total rendering time for areas that are slow to render.  Texture, gradient    and alpha blended backgrounds, for example, can be notibly slow to render;    especially with a transformed view. The CacheBackground flag enables    caching of the view's background. For example:    \code        QGraphicsView view;        view.setBackgroundBrush(QImage(":/images/backgroundtile.png"));        view.setCacheMode(QGraphicsView::CacheBackground);    \endcode    The cache is invalidated every time the view is transformed. However, when    scrolling, only partial invalidation is required.    By default, nothing is cached.    \sa resetCachedContent(), QPixmapCache*/QGraphicsView::CacheMode QGraphicsView::cacheMode() const{    Q_D(const QGraphicsView);    return d->cacheMode;}void QGraphicsView::setCacheMode(CacheMode mode){    Q_D(QGraphicsView);    if (mode == d->cacheMode)        return;    d->cacheMode = mode;    resetCachedContent();}/*!    Resets any cached content. Calling this function will clear    QGraphicsView's cache. If the current cache mode is \l CacheNone, this    function does nothing.    This function is called automatically for you when the backgroundBrush or    QGraphicsScene::backgroundBrush properties change; you only need to call    this function if you have reimplemented QGraphicsScene::drawBackground()    or QGraphicsView::drawBackground() to draw a custom background, and need    to trigger a full redraw.    \sa cacheMode()*/void QGraphicsView::resetCachedContent(){    Q_D(QGraphicsView);    if (d->cacheMode == CacheNone)        return;    if (d->cacheMode & CacheBackground) {        // Background caching is enabled.        d->mustResizeBackgroundPixmap = true;        viewport()->update();    } else if (d->mustResizeBackgroundPixmap) {        // Background caching is disabled.        // Cleanup, free some resources.        d->mustResizeBackgroundPixmap = false;        d->backgroundPixmap = QPixmap();        d->backgroundPixmapExposed = QRegion();    }}/*!    Invalidates and schedules a redraw of \a layers inside \a rect. \a rect is    in scene coordinates. Any cached content for \a layers inside \a rect is    unconditionally invalidated and redrawn.    You can call this function to notify QGraphicsView of changes to the    background or the foreground of the scene. It is commonly used for scenes    with tile-based backgrounds to notify changes when QGraphicsView has    enabled background caching.    Note that QGraphicsView currently supports background caching only (see    QGraphicsView::CacheBackground). This function is equivalent to calling update() if any    layer but QGraphicsScene::BackgroundLayer is passed.    \sa QGraphicsScene::invalidate(), update()*/void QGraphicsView::invalidateScene(const QRectF &rect, QGraphicsScene::SceneLayers layers){    Q_D(QGraphicsView);    if ((layers & QGraphicsScene::BackgroundLayer) && !d->mustResizeBackgroundPixmap) {        QRect viewRect = mapFromScene(rect).boundingRect();        if (viewport()->rect().intersects(viewRect)) {            // The updated background area is exposed; schedule this area for            // redrawing.            d->backgroundPixmapExposed += viewRect;            if (d->scene)                d->scene->update(rect);        }    }}/*!    \property QGraphicsView::interactive    \brief whether the view allowed scene interaction.    If enabled, this view is set to allow scene interaction. Otherwise, this

⌨️ 快捷键说明

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