com.trolltech.qt.gui
Class QGraphicsRectItem

java.lang.Object
  extended by com.trolltech.qt.internal.QSignalEmitterInternal
      extended by com.trolltech.qt.QSignalEmitter
          extended by com.trolltech.qt.QtJambiObject
              extended by com.trolltech.qt.gui.QAbstractGraphicsShapeItem
                  extended by com.trolltech.qt.gui.QGraphicsRectItem
All Implemented Interfaces:
QGraphicsItemInterface, QtJambiInterface

public class QGraphicsRectItem
extends QAbstractGraphicsShapeItem

The QGraphicsRectItem class provides a rectangle item that you can add to a QGraphicsScene. 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.


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.

Note: 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:
QGraphicsPathItem, QGraphicsEllipseItem, QGraphicsPolygonItem, QGraphicsTextItem, QGraphicsLineItem, QGraphicsPixmapItem, and The Graphics View Framework.


Nested Class Summary
static class QGraphicsRectItem.enum_1
           
 
Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter
QSignalEmitter.AbstractSignal, QSignalEmitter.PrivateSignal0, QSignalEmitter.PrivateSignal1, QSignalEmitter.PrivateSignal2, QSignalEmitter.PrivateSignal3, QSignalEmitter.PrivateSignal4, QSignalEmitter.PrivateSignal5, QSignalEmitter.PrivateSignal6, QSignalEmitter.PrivateSignal7, QSignalEmitter.PrivateSignal8, QSignalEmitter.PrivateSignal9, QSignalEmitter.Signal0, QSignalEmitter.Signal1, QSignalEmitter.Signal2, QSignalEmitter.Signal3, QSignalEmitter.Signal4, QSignalEmitter.Signal5, QSignalEmitter.Signal6, QSignalEmitter.Signal7, QSignalEmitter.Signal8, QSignalEmitter.Signal9
 
Nested classes/interfaces inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
com.trolltech.qt.internal.QSignalEmitterInternal.AbstractSignalInternal
 
Field Summary
 
Fields inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
currentSender
 
Constructor Summary
QGraphicsRectItem()
          Constructs a QGraphicsRectItem.
QGraphicsRectItem(double x, double y, double w, double h)
          Creates a new QGraphicsRectItem of which top-left corner is (x, y), width is w, and height is h.
QGraphicsRectItem(double x, double y, double w, double h, QGraphicsItemInterface parent)
          Creates a new QGraphicsRectItem of which top-left corner is (x, y), width is w, and height is h.
QGraphicsRectItem(double x, double y, double w, double h, QGraphicsItemInterface parent, QGraphicsScene scene)
          Creates a new QGraphicsRectItem of which top-left corner is (x, y), width is w, and height is h.
QGraphicsRectItem(QGraphicsItemInterface parent)
          Constructs a QGraphicsRectItem.
QGraphicsRectItem(QGraphicsItemInterface parent, QGraphicsScene scene)
          Constructs a QGraphicsRectItem.
QGraphicsRectItem(QRectF rect)
          Creates a new QGraphicsRectItem with the specified bounds rect.
QGraphicsRectItem(QRectF rect, QGraphicsItemInterface parent)
          Creates a new QGraphicsRectItem with the specified bounds rect and parent.
QGraphicsRectItem(QRectF rect, QGraphicsItemInterface parent, QGraphicsScene scene)
          Creates a new QGraphicsRectItem with the specified bounds rect, parent, and then adds it to scene.
 
Method Summary
 QRectF rect()
          Returns the item's rectangle.
 void setRect(double x, double y, double w, double h)
          Sets the item's rectangle to the rectangle defined by (x, y) and the given width and height.
 void setRect(QRectF rect)
          Sets the item's rectangle to be the given rectangle.
 
Methods inherited from class com.trolltech.qt.gui.QAbstractGraphicsShapeItem
acceptDrops, acceptedMouseButtons, acceptHoverEvents, acceptsHoverEvents, advance, boundingRect, boundingRegion, boundingRegionGranularity, brush, cacheMode, childItems, childrenBoundingRect, clearFocus, clipPath, collidesWithItem, collidesWithPath, collidingItems, commonAncestorItem, contains, contextMenuEvent, cursor, data, deviceTransform, dragEnterEvent, dragLeaveEvent, dragMoveEvent, dropEvent, effectiveOpacity, ensureVisible, ensureVisible, flags, focusInEvent, focusOutEvent, grabKeyboard, grabMouse, group, handlesChildEvents, hasCursor, hasFocus, hide, hoverEnterEvent, hoverLeaveEvent, hoverMoveEvent, inputMethodEvent, inputMethodQuery, installSceneEventFilter, isAncestorOf, isClipped, isEnabled, isObscured, isObscured, isObscured, isObscuredBy, isSelected, isUnderMouse, isVisible, isVisibleTo, isWidget, isWindow, itemChange, itemTransform, keyPressEvent, keyReleaseEvent, mapFromItem, mapFromItem, mapFromItem, mapFromItem, mapFromItem, mapFromItem, mapFromParent, mapFromParent, mapFromParent, mapFromParent, mapFromParent, mapFromParent, mapFromScene, mapFromScene, mapFromScene, mapFromScene, mapFromScene, mapFromScene, mapRectFromItem, mapRectFromItem, mapRectFromParent, mapRectFromParent, mapRectFromScene, mapRectFromScene, mapRectToItem, mapRectToItem, mapRectToParent, mapRectToParent, mapRectToScene, mapRectToScene, mapToItem, mapToItem, mapToItem, mapToItem, mapToItem, mapToItem, mapToParent, mapToParent, mapToParent, mapToParent, mapToParent, mapToParent, mapToScene, mapToScene, mapToScene, mapToScene, mapToScene, mapToScene, mouseDoubleClickEvent, mouseMoveEvent, mousePressEvent, mouseReleaseEvent, moveBy, opacity, opaqueArea, paint, parentItem, parentWidget, pen, pos, prepareGeometryChange, removeSceneEventFilter, resetTransform, rotate, scale, scene, sceneBoundingRect, sceneEvent, sceneEventFilter, scenePos, sceneTransform, scroll, setAcceptDrops, setAcceptedMouseButtons, setAcceptHoverEvents, setAcceptsHoverEvents, setBoundingRegionGranularity, setBrush, setCacheMode, setCursor, setData, setEnabled, setFlag, setFlags, setFocus, setGroup, setHandlesChildEvents, setOpacity, setParentItem, setPen, setPos, setPos, setSelected, setToolTip, setTransform, setVisible, setZValue, shape, shear, show, toolTip, topLevelItem, topLevelWidget, transform, translate, type, ungrabKeyboard, ungrabMouse, unsetCursor, update, update, wheelEvent, window, x, y, zValue
 
Methods inherited from class com.trolltech.qt.QtJambiObject
dispose, disposed, equals, finalize, reassignNativeResources, tr, tr, tr
 
Methods inherited from class com.trolltech.qt.QSignalEmitter
blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread
 
Methods inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
__qt_signalInitialization
 
Methods inherited from class java.lang.Object
clone, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.trolltech.qt.QtJambiInterface
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership
 

Constructor Detail

QGraphicsRectItem

public QGraphicsRectItem(QGraphicsItemInterface parent)
Constructs a QGraphicsRectItem. parent is passed to QAbstractGraphicsShapeItem's constructor.The item is added to the scene.

See also:
QGraphicsScene::addItem().


QGraphicsRectItem

public QGraphicsRectItem()
Constructs a QGraphicsRectItem. parent is passed to QAbstractGraphicsShapeItem's constructor.The item is added to the scene.

See also:
QGraphicsScene::addItem().


QGraphicsRectItem

public QGraphicsRectItem(QGraphicsItemInterface parent,
                         QGraphicsScene scene)
Constructs a QGraphicsRectItem. parent is passed to QAbstractGraphicsShapeItem's constructor.The item is added to the scene.

See also:
QGraphicsScene::addItem().


QGraphicsRectItem

public QGraphicsRectItem(QRectF rect,
                         QGraphicsItemInterface parent)
Creates a new QGraphicsRectItem with the specified bounds rect and parent.


QGraphicsRectItem

public QGraphicsRectItem(QRectF rect)
Creates a new QGraphicsRectItem with the specified bounds rect.


QGraphicsRectItem

public QGraphicsRectItem(QRectF rect,
                         QGraphicsItemInterface parent,
                         QGraphicsScene scene)
Creates a new QGraphicsRectItem with the specified bounds rect, parent, and then adds it to scene.


QGraphicsRectItem

public QGraphicsRectItem(double x,
                         double y,
                         double w,
                         double h,
                         QGraphicsItemInterface parent)
Creates a new QGraphicsRectItem of which top-left corner is (x, y), width is w, and height is h. It will have the specified parent.


QGraphicsRectItem

public QGraphicsRectItem(double x,
                         double y,
                         double w,
                         double h)
Creates a new QGraphicsRectItem of which top-left corner is (x, y), width is w, and height is h.


QGraphicsRectItem

public QGraphicsRectItem(double x,
                         double y,
                         double w,
                         double h,
                         QGraphicsItemInterface parent,
                         QGraphicsScene scene)
Creates a new QGraphicsRectItem of which top-left corner is (x, y), width is w, and height is h. It will have the specified parent and scene.

Method Detail

rect

public final QRectF rect()
Returns the item's rectangle.

See also:
setRect().


setRect

public final void setRect(QRectF rect)
Sets the item's rectangle to be the given rectangle.

See also:
rect().


setRect

public final void setRect(double x,
                          double y,
                          double w,
                          double h)
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:
rect().