|
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.trolltech.qt.QSignalEmitter
com.trolltech.qt.QtJambiObject
com.trolltech.qt.core.QObject
com.trolltech.qt.gui.QWidget
com.trolltech.qt.gui.QRubberBand
public class QRubberBand
The QRubberBand class provides a rectangle or line that can indicate a selection or a boundary.
A rubber band is often used to show a new bounding area (as in a QSplitter or a QDockWidget that is undocking). Historically this has been implemented using a QPainter 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 "erased".
You can create a QRubberBand whenever you need to render a rubber band around a given area (or to represent a single line), then call setGeometry, move or resize to position and size it. A common pattern is to do this in conjunction with mouse events. For example:
void Widget::mousePressEvent(QMouseEvent *event) { origin = event->pos(); if (!rubberBand) rubberBand = new QRubberBand(QRubberBand::Rectangle, this); rubberBand->setGeometry(QRect(origin, QSize())); rubberBand->show(); } void Widget::mouseMoveEvent(QMouseEvent *event) { rubberBand->setGeometry(QRect(origin, event->pos()).normalized()); } void Widget::mouseReleaseEvent(QMouseEvent *event) { rubberBand->hide(); // determine selection, for example using QRect::intersects() // and QRect::contains(). }
If you pass a parent to QRubberBand's constructor, the rubber band will display only inside its parent, but stays on top of other child widgets. If no parent is passed, QRubberBand will act as a top-level widget.
Call show 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 Rectangle or a Line (vertical or horizontal), depending on the shape it was given when constructed.
Nested Class Summary | |
---|---|
static class |
QRubberBand.Shape
This enum specifies what shape a QRubberBand should have. |
Nested classes/interfaces inherited from class com.trolltech.qt.gui.QWidget |
---|
QWidget.RenderFlag, QWidget.RenderFlags |
Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter |
---|
QSignalEmitter.AbstractSignal, QSignalEmitter.Signal0, QSignalEmitter.Signal1<A>, QSignalEmitter.Signal2<A,B>, QSignalEmitter.Signal3<A,B,C>, QSignalEmitter.Signal4<A,B,C,D>, QSignalEmitter.Signal5<A,B,C,D,E>, QSignalEmitter.Signal6<A,B,C,D,E,F>, QSignalEmitter.Signal7<A,B,C,D,E,F,G>, QSignalEmitter.Signal8<A,B,C,D,E,F,G,H>, QSignalEmitter.Signal9<A,B,C,D,E,F,G,H,I> |
Field Summary |
---|
Fields inherited from class com.trolltech.qt.gui.QWidget |
---|
customContextMenuRequested |
Constructor Summary | |
---|---|
QRubberBand(QRubberBand.Shape arg__1)
Equivalent to QRubberBand(arg__1, 0). |
|
QRubberBand(QRubberBand.Shape arg__1,
QWidget arg__2)
Constructs a rubber band of shape arg__1, with parent arg__2. |
Method Summary | |
---|---|
protected void |
changeEvent(QEvent arg__1)
This function is reimplemented for internal reasons. |
boolean |
event(QEvent e)
This function is reimplemented for internal reasons. |
static QRubberBand |
fromNativePointer(QNativePointer nativePointer)
This function returns the QRubberBand instance pointed to by nativePointer |
protected void |
initStyleOption(QStyleOptionRubberBand option)
This is a overloaded function provided for convenience. |
protected void |
moveEvent(QMoveEvent arg__1)
This function is reimplemented for internal reasons. |
void |
moveRubberBand(int x,
int y)
Moves the rubberband to point (x, y). |
void |
moveRubberBand(QPoint p)
Moves the rubberband to point p. |
protected void |
paintEvent(QPaintEvent arg__1)
This function is reimplemented for internal reasons. |
protected void |
resizeEvent(QResizeEvent arg__1)
This function is reimplemented for internal reasons. |
void |
resizeRubberBand(int w,
int h)
Resizes the rubberband so that its width is w, and its height is h. |
void |
resizeRubberBand(QSize s)
Resizes the rubberband so that its new size is s. |
void |
setRubberBandGeometry(int x,
int y,
int w,
int h)
Sets the geometry of the rubberband to the rectangle whose top-left corner lies at the point (x, y), and with dimensions specified by w and h. |
void |
setRubberBandGeometry(QRect r)
Sets the geometry of the rubber band to r, specified in the coordinate system of its parent widget. |
QRubberBand.Shape |
shape()
Returns the shape of this rubber band. |
protected void |
showEvent(QShowEvent arg__1)
This function is reimplemented for internal reasons. |
Methods inherited from class com.trolltech.qt.core.QObject |
---|
blockSignals, childEvent, children, connectSlotsByName, customEvent, disposeLater, dumpObjectInfo, dumpObjectTree, dynamicPropertyNames, eventFilter, findChild, findChild, findChild, findChildren, findChildren, findChildren, findChildren, installEventFilter, isWidgetType, killTimer, moveToThread, objectName, parent, property, removeEventFilter, setObjectName, setParent, setProperty, signalsBlocked, startTimer, thread, timerEvent |
Methods inherited from class com.trolltech.qt.QtJambiObject |
---|
dispose, disposed, finalize, reassignNativeResources, tr, tr, tr |
Methods inherited from class com.trolltech.qt.QSignalEmitter |
---|
disconnect, disconnect, signalSender |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.trolltech.qt.QtJambiInterface |
---|
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership |
Constructor Detail |
---|
public QRubberBand(QRubberBand.Shape arg__1)
Equivalent to QRubberBand(arg__1, 0).
public QRubberBand(QRubberBand.Shape arg__1, QWidget arg__2)
Constructs a rubber band of shape arg__1, with parent arg__2.
By default a rectangular rubber band (arg__1 is Rectangle) will use a mask, so that a small border of the rectangle is all that is visible. Some styles (e.g., native Mac OS X) will change this and call QWidget::setWindowOpacity() to make a semi-transparent filled selection rectangle.
Method Detail |
---|
public final void moveRubberBand(QPoint p)
Moves the rubberband to point p.
public final void moveRubberBand(int x, int y)
Moves the rubberband to point (x, y).
public final void resizeRubberBand(int w, int h)
Resizes the rubberband so that its width is w, and its height is h.
public final void resizeRubberBand(QSize s)
Resizes the rubberband so that its new size is s.
public final void setRubberBandGeometry(int x, int y, int w, int h)
Sets the geometry of the rubberband to the rectangle whose top-left corner lies at the point (x, y), and with dimensions specified by w and h. The geometry is specified in the parent widget's coordinate system.
public final void setRubberBandGeometry(QRect r)
Sets the geometry of the rubber band to r, specified in the coordinate system of its parent widget.
public final QRubberBand.Shape shape()
Returns the shape of this rubber band. The shape can only be set upon construction.
protected void changeEvent(QEvent arg__1)
This function is reimplemented for internal reasons.
changeEvent
in class QWidget
public boolean event(QEvent e)
This function is reimplemented for internal reasons.
event
in class QWidget
protected void moveEvent(QMoveEvent arg__1)
This function is reimplemented for internal reasons.
moveEvent
in class QWidget
protected void paintEvent(QPaintEvent arg__1)
This function is reimplemented for internal reasons.
paintEvent
in class QWidget
protected void resizeEvent(QResizeEvent arg__1)
This function is reimplemented for internal reasons.
resizeEvent
in class QWidget
Example
protected void showEvent(QShowEvent arg__1)
This function is reimplemented for internal reasons.
showEvent
in class QWidget
visible
,
event,
QShowEventpublic static QRubberBand fromNativePointer(QNativePointer nativePointer)
nativePointer
- the QNativePointer of which object should be returned.protected final void initStyleOption(QStyleOptionRubberBand option)
|
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |