<class name="QRubberBand" doc="/** <p>The <a href="QRubberBand.html#QRubberBand(com.trolltech.qt.gui.QRubberBand.Shape, com.trolltech.qt.gui.QWidget)"><tt>QRubberBand</tt></a> class provides a rectangle or line that can indicate a selection or a boundary.</p> <p>A rubber band is often used to show a new bounding area (as in a <a href="QSplitter.html"><tt>QSplitter</tt></a> or a <a href="QDockWidget.html"><tt>QDockWidget</tt></a> that is undocking). Historically this has been implemented using a <a href="QPainter.html"><tt>QPainter</tt></a> and XOR, but this approach doesn't always work properly since rendering can happen in the window below the rubber band, but before the rubber band has been &quot;erased&quot;.</p> <p>You can create a <a href="QRubberBand.html#QRubberBand(com.trolltech.qt.gui.QRubberBand.Shape, com.trolltech.qt.gui.QWidget)"><tt>QRubberBand</tt></a> whenever you need to render a rubber band around a given area (or to represent a single line), then call <a href="QWidget.html#setGeometry(com.trolltech.qt.core.QRect)"><tt>setGeometry</tt></a>, <a href="QWidget.html#move(com.trolltech.qt.core.QPoint)"><tt>move</tt></a> or <a href="QWidget.html#resize(com.trolltech.qt.core.QSize)"><tt>resize</tt></a> to position and size it. A common pattern is to do this in conjunction with mouse events. For example:</p> <pre> void Widget::mousePressEvent(QMouseEvent *event) { origin = event-&gt;pos(); if (!rubberBand) rubberBand = new QRubberBand(QRubberBand::Rectangle, this); rubberBand-&gt;setGeometry(QRect(origin, QSize())); rubberBand-&gt;show(); } void Widget::mouseMoveEvent(QMouseEvent *event) { rubberBand-&gt;setGeometry(QRect(origin, event-&gt;pos()).normalized()); } void Widget::mouseReleaseEvent(QMouseEvent *event) { rubberBand-&gt;hide(); <span class="comment">// determine selection, for example using QRect::intersects()</span> <span class="comment">// and QRect::contains().</span> }</pre> <p>If you pass a parent to <a href="QRubberBand.html#QRubberBand(com.trolltech.qt.gui.QRubberBand.Shape, com.trolltech.qt.gui.QWidget)"><tt>QRubberBand</tt></a>'s constructor, the rubber band will display only inside its parent, but stays on top of other child widgets. If no parent is passed, <a href="QRubberBand.html#QRubberBand(com.trolltech.qt.gui.QRubberBand.Shape, com.trolltech.qt.gui.QWidget)"><tt>QRubberBand</tt></a> will act as a top-level widget.</p> <p>Call <a href="QWidget.html#show()"><tt>show</tt></a> to make the rubber band visible; also when the rubber band is not a top-level. Hiding or destroying the widget will make the rubber band disappear. The rubber band can be a <a href="QRubberBand.html#Shape-enum">Rectangle</tt></a> or a <a href="QRubberBand.html#Shape-enum">Line</tt></a> (vertical or horizontal), depending on the <a href="QRubberBand.html#shape()"><tt>shape</tt></a> it was given when constructed.</p> */"> <signal name="protected final void customContextMenuRequested(com.trolltech.qt.core.QPoint pos)" doc="/** <p>This signal is emitted when the widget's <a href="QWidget.html#contextMenuPolicy()"><tt>contextMenuPolicy</tt></a> is Qt::CustomContextMenu, and the user has requested a context menu on the widget. The position <tt>pos</tt> is the position of the context menu event that the widget receives. Normally this is in widget coordinates. The exception to this rule is <a href="QAbstractScrollArea.html"><tt>QAbstractScrollArea</tt></a> and its subclasses that map the context menu event to coordinates of the viewport()</tt> .</p> <dl> <dt><b>Compatible Slot Signatures:</b></dt> <dd><tt>void mySlot(com.trolltech.qt.core.QPoint pos)</tt></dd> <dd><tt>void mySlot()</tt></dd> </dl> <dl> <dt><b>See Also:</b></dt> <dd><a href="QWidget.html#mapToGlobal(com.trolltech.qt.core.QPoint)"><tt>mapToGlobal</tt></a>, <a href="QMenu.html"><tt>QMenu</tt></a>, <a href="QWidget.html#contextMenuPolicy()"><tt>contextMenuPolicy</tt></a></dd> </dl> */"/> <method name="public QRubberBand(com.trolltech.qt.gui.QRubberBand.Shape arg__1, com.trolltech.qt.gui.QWidget arg__2)" doc="/** <p>Constructs a rubber band of shape <tt>arg__1</tt>, with parent <tt>arg__2</tt>.</p> <p>By default a rectangular rubber band (<tt>arg__1</tt> is <tt>Rectangle</tt>) will use a mask, so that a small border of the rectangle is all that is visible. Some styles (e.g&#x2e;, native Mac OS X) will change this and call QWidget::setWindowOpacity() to make a semi-transparent filled selection rectangle.</p> */"/> <method name="public QRubberBand(com.trolltech.qt.gui.QRubberBand.Shape arg__1)" doc="/** <p>Equivalent to <a href="QRubberBand.html#QRubberBand(com.trolltech.qt.gui.QRubberBand.Shape, com.trolltech.qt.gui.QWidget)"><tt>QRubberBand</tt></a>(<tt>arg__1</tt>, 0). */"/> <method name="public final void moveRubberBand(int x, int y)" doc="/** <p>Moves the rubberband to point (<tt>x</tt>, <tt>y</tt>).</p> @see <a href="QWidget.html#resize(com.trolltech.qt.core.QSize)"><tt>resize</tt></a> */"/> <method name="public final void moveRubberBand(com.trolltech.qt.core.QPoint p)" doc="/** <p>Moves the rubberband to point <tt>p</tt>.</p> @see <a href="QWidget.html#resize(com.trolltech.qt.core.QSize)"><tt>resize</tt></a> */"/> <method name="public final void resizeRubberBand(com.trolltech.qt.core.QSize s)" doc="/** <p>Resizes the rubberband so that its new size is <tt>s</tt>.</p> @see <a href="QWidget.html#move(com.trolltech.qt.core.QPoint)"><tt>move</tt></a> */"/> <method name="public final void resizeRubberBand(int w, int h)" doc="/** <p>Resizes the rubberband so that its width is <tt>w</tt>, and its height is <tt>h</tt>.</p> @see <a href="QWidget.html#move(com.trolltech.qt.core.QPoint)"><tt>move</tt></a> */"/> <method name="public final void setRubberBandGeometry(com.trolltech.qt.core.QRect r)" doc="/** <p>Sets the geometry of the rubber band to <tt>r</tt>, specified in the coordinate system of its parent widget.</p> @see <tt>QWidget::geometry</tt> */"/> <method name="public final void setRubberBandGeometry(int x, int y, int w, int h)" doc="/** <p>Sets the geometry of the rubberband to the rectangle whose top-left corner lies at the point (<tt>x</tt>, <tt>y</tt>), and with dimensions specified by <tt>w</tt> and <tt>h</tt>. The geometry is specified in the parent widget's coordinate system.</p> */"/> <method name="public final com.trolltech.qt.gui.QRubberBand.Shape shape()" doc="/** <p>Returns the shape of this rubber band. The shape can only be set upon construction.</p> */"/> <method name="protected void changeEvent(com.trolltech.qt.core.QEvent arg__1)" doc="/** <p>This function is reimplemented for internal reasons.</p> */"/> <method name="public boolean event(com.trolltech.qt.core.QEvent e)" doc="/** <p>This function is reimplemented for internal reasons.</p> */"/> <method name="protected void moveEvent(com.trolltech.qt.gui.QMoveEvent arg__1)" doc="/** <p>This function is reimplemented for internal reasons.</p> */"/> <method name="protected void paintEvent(com.trolltech.qt.gui.QPaintEvent arg__1)" doc="/** <p>This function is reimplemented for internal reasons.</p> */"/> <method name="protected void resizeEvent(com.trolltech.qt.gui.QResizeEvent arg__1)" doc="/** <p>This function is reimplemented for internal reasons.</p> */"/> <method name="protected void showEvent(com.trolltech.qt.gui.QShowEvent arg__1)" doc="/** <p>This function is reimplemented for internal reasons.</p> */"/> <enum name="Shape" doc="/** <p>This enum specifies what shape a <a href="QRubberBand.html#QRubberBand(com.trolltech.qt.gui.QRubberBand.Shape, com.trolltech.qt.gui.QWidget)"><tt>QRubberBand</tt></a> should have. This is a drawing hint that is passed down to the style system, and can be interpreted by each <a href="QStyle.html"><tt>QStyle</tt></a>.</p> */"> <enum-value name="Line" doc="/** <p>A <a href="QRubberBand.html#QRubberBand(com.trolltech.qt.gui.QRubberBand.Shape, com.trolltech.qt.gui.QWidget)"><tt>QRubberBand</tt></a> can represent a vertical or horizontal line. Geometry is still given in <a href="QWidget.html#rect()"><tt>rect</tt></a> and the line will fill the given geometry on most styles.</p> */"/> <enum-value name="Rectangle" doc="/** <p>A <a href="QRubberBand.html#QRubberBand(com.trolltech.qt.gui.QRubberBand.Shape, com.trolltech.qt.gui.QWidget)"><tt>QRubberBand</tt></a> can represent a rectangle. Some styles will interpret this as a filled (often semi-transparent) rectangle, or a rectangular outline.</p> */"/> </enum> </class>