IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)

QGraphicsRectItem Class

The QGraphicsRectItem class provides a rectangle item that you can add to a QGraphicsScene.

Article lu   fois.

L'auteur

Liens sociaux

Viadeo Twitter Facebook Share on Google+   

QGraphicsRectItem Class▲

  • Header: QGraphicsRectItem

  • CMake:

    find_package(Qt6 REQUIRED COMPONENTS Widgets)

    target_link_libraries(mytarget PRIVATE Qt6::Widgets)

  • qmake: QT += widgets

  • Inherits: QAbstractGraphicsShapeItem

  • Group: QGraphicsRectItem is part of graphicsview-api

Detailed Description▲

To set the item's rectangle, pass a QRectF to QGraphicsRectItem's constructor, or call the setRect() function. The rect() function returns the current rectangle.

Image non disponible

QGraphicsRectItem uses the rectangle and the pen width to provide a reasonable implementation of boundingRect(), shape(), and contains(). The paint() function draws the rectangle using the item's associated pen and brush, which you can set by calling the setPen() and setBrush() functions.

The rendering of invalid rectangles, such as those with negative widths or heights, is undefined. If you cannot be sure that you are using valid rectangles (for example, if you are creating rectangles using data from an unreliable source) then you should use QRectF::normalized() to create normalized rectangles, and use those instead.

See Also▲

Member Type Documentation▲

 

enum QGraphicsRectItem::anonymous▲

The value returned by the virtual type() function.

Constant

Value

Description

QGraphicsRectItem::Type

3

A graphics rect item

Member Function Documentation▲

 

void QGraphicsRectItem::setRect(qreal x, qreal y, qreal width, qreal height)▲

Sets the item's rectangle to the rectangle defined by (x, y) and the given width and height.

This convenience function is equivalent to calling setRect(QRectF(x, y, width, height))

See Also▲

See also rect()

[explicit] QGraphicsRectItem::QGraphicsRectItem(QGraphicsItem *parent = nullptr)▲

Constructs a QGraphicsRectItem. parent is passed to QAbstractGraphicsShapeItem's constructor.

See Also▲

[explicit] QGraphicsRectItem::QGraphicsRectItem(const QRectF &rect, QGraphicsItem *parent = nullptr)▲

Constructs a QGraphicsRectItem, using rect as the default rectangle. parent is passed to QAbstractGraphicsShapeItem's constructor.

See Also▲

[explicit] QGraphicsRectItem::QGraphicsRectItem(qreal x, qreal y, qreal width, qreal height, QGraphicsItem *parent = nullptr)▲

Constructs a QGraphicsRectItem with a default rectangle defined by (x, y) and the given width and height.

parent is passed to QAbstractGraphicsShapeItem's constructor.

See Also▲

[virtual] QGraphicsRectItem::~QGraphicsRectItem()▲

Destroys the QGraphicsRectItem.

[override virtual] QRectF QGraphicsRectItem::boundingRect() const▲

[override virtual] bool QGraphicsRectItem::contains(const QPointF &point) const▲

[override virtual] bool QGraphicsRectItem::isObscuredBy(const QGraphicsItem *item) const▲

[override virtual] QPainterPath QGraphicsRectItem::opaqueArea() const▲

[override virtual] void QGraphicsRectItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr)▲

QRectF QGraphicsRectItem::rect() const▲

Returns the item's rectangle.

See Also▲

See also setRect()

void QGraphicsRectItem::setRect(const QRectF &rectangle)▲

Sets the item's rectangle to be the given rectangle.

See Also▲

See also rect()

[override virtual] QPainterPath QGraphicsRectItem::shape() const▲

[override virtual] int QGraphicsRectItem::type() const▲

Vous avez aimé ce tutoriel ? Alors partagez-le en cliquant sur les boutons suivants : Viadeo Twitter Facebook Share on Google+