The QRubberBand class provides a rectangle or line that can indicate a selection or a boundary.
More...
|
| QRubberBand (Shape shape, QWidget *parent=nullptr) |
|
| ~QRubberBand () |
|
void | move (const QPoint &point) |
|
void | move (int x, int y) |
|
void | resize (const QSize &size) |
|
void | resize (int width, int height) |
|
void | setGeometry (const QRect &rect) |
|
void | setGeometry (int x, int y, int width, int height) |
|
Shape | shape () const |
|
| QWidget (QWidget *parent=nullptr, Qt::WindowFlags flags=Qt::EmptyFlag) |
|
| ~QWidget () |
|
bool | acceptDrops () const |
|
QString | accessibleDescription () const |
|
QString | accessibleName () const |
|
QList< QAction * > | actions () const |
|
void | activateWindow () |
|
void | addAction (QAction *action) |
|
void | addActions (const QList< QAction * > &actions) |
|
void | adjustSize () |
|
bool | autoFillBackground () const |
|
QPalette::ColorRole | backgroundRole () const |
|
QBackingStore * | backingStore () const |
|
QSize | baseSize () const |
|
QWidget * | childAt (const QPoint &position) const |
|
QWidget * | childAt (int x, int y) const |
|
QRect | childrenRect () const |
|
QRegion | childrenRegion () const |
|
void | clearFocus () |
|
void | clearMask () |
|
QMargins | contentsMargins () const |
|
QRect | contentsRect () const |
|
Qt::ContextMenuPolicy | contextMenuPolicy () const |
|
QCursor | cursor () const |
|
WId | effectiveWinId () const |
|
void | ensurePolished () const |
|
Qt::FocusPolicy | focusPolicy () const |
|
QWidget * | focusProxy () const |
|
QWidget * | focusWidget () const |
|
const QFont & | font () const |
|
QFontInfo | fontInfo () const |
|
QFontMetrics | fontMetrics () const |
|
QPalette::ColorRole | foregroundRole () const |
|
QRect | frameGeometry () const |
|
QSize | frameSize () const |
|
const QRect & | geometry () const |
|
void | getContentsMargins (int *left, int *top, int *right, int *bottom) const |
|
QPixmap | grab (const QRect &rectangle=QRect (QPoint (0, 0), QSize (-1,-1))) |
|
void | grabGesture (Qt::GestureType gestureType, Qt::GestureFlags flags=Qt::GestureFlags ()) |
|
void | grabKeyboard () |
|
void | grabMouse () |
|
void | grabMouse (const QCursor &cursor) |
|
int | grabShortcut (const QKeySequence &key, Qt::ShortcutContext context=Qt::WindowShortcut) |
|
QGraphicsEffect * | graphicsEffect () const |
|
QGraphicsProxyWidget * | graphicsProxyWidget () const |
|
bool | hasEditFocus () const |
|
bool | hasFocus () const |
|
virtual bool | hasHeightForWidth () const |
|
bool | hasMouseTracking () const |
|
int | height () const |
|
virtual int | heightForWidth (int width) const |
|
Qt::InputMethodHints | inputMethodHints () const |
|
virtual QVariant | inputMethodQuery (Qt::InputMethodQuery query) const |
|
void | insertAction (QAction *before, QAction *action) |
|
void | insertActions (QAction *before, QList< QAction * > actions) |
|
bool | isActiveWindow () const |
|
bool | isAncestorOf (const QWidget *child) const |
|
bool | isEnabled () const |
|
bool | isEnabledTo (const QWidget *parent) const |
|
bool | isEnabledToTLW () const |
|
bool | isFullScreen () const |
|
bool | isHidden () const |
|
bool | isMaximized () const |
|
bool | isMinimized () const |
|
bool | isModal () const |
|
bool | isTopLevel () const |
|
bool | isVisible () const |
|
bool | isVisibleTo (const QWidget *parent) const |
|
bool | isWindow () const |
|
bool | isWindowModified () const |
|
QLayout * | layout () const |
|
Qt::LayoutDirection | layoutDirection () const |
|
QLocale | locale () const |
|
QPoint | mapFrom (const QWidget *parent, const QPoint &pos) const |
|
QPoint | mapFromGlobal (const QPoint &pos) const |
|
QPoint | mapFromParent (const QPoint &pos) const |
|
QPoint | mapTo (const QWidget *parent, const QPoint &pos) const |
|
QPoint | mapToGlobal (const QPoint &pos) const |
|
QPoint | mapToParent (const QPoint &pos) const |
|
QRegion | mask () const |
|
int | maximumHeight () const |
|
QSize | maximumSize () const |
|
int | maximumWidth () const |
|
int | minimumHeight () const |
|
QSize | minimumSize () const |
|
virtual QSize | minimumSizeHint () const |
|
int | minimumWidth () const |
|
void | move (const QPoint &point) |
|
void | move (int x, int y) |
|
QWidget * | nativeParentWidget () const |
|
QWidget * | nextInFocusChain () const |
|
QRect | normalGeometry () const |
|
void | overrideWindowFlags (Qt::WindowFlags flags) |
|
QPaintEngine * | paintEngine () const override |
|
const QPalette & | palette () const |
|
QWidget * | parentWidget () const |
|
QPoint | pos () const |
|
QWidget * | previousInFocusChain () const |
|
QRect | rect () const |
|
void | releaseKeyboard () |
|
void | releaseMouse () |
|
void | releaseShortcut (int id) |
|
void | removeAction (QAction *action) |
|
void | render (QPaintDevice *target, const QPoint &targetOffset=QPoint (), const QRegion &sourceRegion=QRegion (), RenderFlags renderFlags=RenderFlags (DrawWindowBackground|DrawChildren)) |
|
void | render (QPainter *painter, const QPoint &targetOffset=QPoint (), const QRegion &sourceRegion=QRegion (), RenderFlags renderFlags=RenderFlags (DrawWindowBackground|DrawChildren)) |
|
void | repaint (const QRect &rect) |
|
void | repaint (const QRegion ®ion) |
|
void | repaint (int x, int y, int w, int h) |
|
void | resize (const QSize &size) |
|
void | resize (int w, int h) |
|
bool | restoreGeometry (const QByteArray &geometry) |
|
QByteArray | saveGeometry () const |
|
void | scroll (int dx, int dy) |
|
void | scroll (int dx, int dy, const QRect &rect) |
|
void | setAcceptDrops (bool on) |
|
void | setAccessibleDescription (const QString &description) |
|
void | setAccessibleName (const QString &name) |
|
void | setAttribute (Qt::WidgetAttribute attribute, bool enable=true) |
|
void | setAutoFillBackground (bool enable) |
|
void | setBackgroundRole (QPalette::ColorRole role) |
|
void | setBaseSize (const QSize &size) |
|
void | setBaseSize (int basew, int baseh) |
|
void | setContentsMargins (const QMargins &margins) |
|
void | setContentsMargins (int left, int top, int right, int bottom) |
|
void | setContextMenuPolicy (Qt::ContextMenuPolicy policy) |
|
void | setCursor (const QCursor &cursor) |
|
void | setEditFocus (bool enable) |
|
void | setFixedHeight (int h) |
|
void | setFixedSize (const QSize &size) |
|
void | setFixedSize (int w, int h) |
|
void | setFixedWidth (int w) |
|
void | setFocus (Qt::FocusReason reason) |
|
void | setFocusPolicy (Qt::FocusPolicy policy) |
|
void | setFocusProxy (QWidget *widget) |
|
void | setFont (const QFont &font) |
|
void | setForegroundRole (QPalette::ColorRole role) |
|
void | setGeometry (const QRect &rect) |
|
void | setGeometry (int x, int y, int w, int h) |
|
void | setGraphicsEffect (QGraphicsEffect *effect) |
|
void | setInputMethodHints (Qt::InputMethodHints hints) |
|
void | setLayout (QLayout *layout) |
|
void | setLayoutDirection (Qt::LayoutDirection direction) |
|
void | setLocale (const QLocale &locale) |
|
void | setMask (const QBitmap &bitmap) |
|
void | setMask (const QRegion ®ion) |
|
void | setMaximumHeight (int maxh) |
|
void | setMaximumSize (const QSize &size) |
|
void | setMaximumSize (int maxw, int maxh) |
|
void | setMaximumWidth (int maxw) |
|
void | setMinimumHeight (int minh) |
|
void | setMinimumSize (const QSize &size) |
|
void | setMinimumSize (int minw, int minh) |
|
void | setMinimumWidth (int minw) |
|
void | setMouseTracking (bool enable) |
|
void | setPalette (const QPalette &palette) |
|
void | setParent (QWidget *parent) |
|
void | setParent (QWidget *parent, Qt::WindowFlags flags) |
|
void | setShortcutAutoRepeat (int id, bool enable=true) |
|
void | setShortcutEnabled (int id, bool enable=true) |
|
void | setSizeIncrement (const QSize &size) |
|
void | setSizeIncrement (int w, int h) |
|
void | setSizePolicy (QSizePolicy policy) |
|
void | setSizePolicy (QSizePolicy::Policy horizontal, QSizePolicy::Policy vertical) |
|
void | setStatusTip (const QString &data) |
|
void | setStyle (QStyle *style) |
|
void | setToolTip (const QString &data) |
|
void | setToolTipDuration (int msec) |
|
void | setUpdatesEnabled (bool enable) |
|
void | setWhatsThis (const QString &str) |
|
void | setWindowFilePath (const QString &filePath) |
|
void | setWindowFlags (Qt::WindowFlags flags) |
|
void | setWindowIcon (const QIcon &icon) |
|
void | setWindowModality (Qt::WindowModality windowModality) |
|
void | setWindowOpacity (qreal level) |
|
void | setWindowRole (const QString &role) |
|
void | setWindowState (Qt::WindowStates windowState) |
|
QSize | size () const |
|
virtual QSize | sizeHint () const |
|
QSize | sizeIncrement () const |
|
QSizePolicy | sizePolicy () const |
|
void | stackUnder (QWidget *widget) |
|
QString | statusTip () const |
|
QStyle * | style () const |
|
QString | styleSheet () const |
|
bool | testAttribute (Qt::WidgetAttribute attribute) const |
|
QString | toolTip () const |
|
int | toolTipDuration () const |
|
QWidget * | topLevelWidget () const |
|
bool | underMouse () const |
|
void | ungrabGesture (Qt::GestureType gestureType) |
|
void | unsetCursor () |
|
void | unsetLayoutDirection () |
|
void | unsetLocale () |
|
void | update (const QRect &rect) |
|
void | update (const QRegion ®ion) |
|
void | update (int x, int y, int w, int h) |
|
void | updateGeometry () |
|
bool | updatesEnabled () const |
|
QRegion | visibleRegion () const |
|
QString | whatsThis () const |
|
int | width () const |
|
QWidget * | window () const |
|
QString | windowFilePath () const |
|
Qt::WindowFlags | windowFlags () const |
|
QWindow * | windowHandle () const |
|
QIcon | windowIcon () const |
|
Qt::WindowModality | windowModality () const |
|
qreal | windowOpacity () const |
|
QString | windowRole () const |
|
Qt::WindowStates | windowState () const |
|
QString | windowTitle () const |
|
Qt::WindowType | windowType () const |
|
WId | winId () const |
|
int | x () const |
|
int | y () const |
|
| QObject (QObject *parent=nullptr) |
|
| ~QObject () |
|
bool | blockSignals (bool block) |
|
const QList< QObject * > & | children () const |
|
bool | connect (const QObject *sender, const QString &signalMethod, const QString &location, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection) |
|
bool | connect (const QObject *sender, const QString &signalMethod, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection) |
|
bool | disconnect (const QObject *receiver, const QString &slotMethod=QString ()) const |
|
bool | disconnect (const QString &signalMethod, const QString &location, const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const |
|
bool | disconnect (const QString &signalMethod=QString (), const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const |
|
void | dumpObjectInfo () |
|
void | dumpObjectTree () |
|
QList< QString > | dynamicPropertyNames () const |
|
virtual bool | event (QEvent *event) |
|
virtual bool | eventFilter (QObject *watched, QEvent *event) |
|
template<typename T > |
T | findChild (const QString &childName=QString ()) const |
|
template<class T > |
QList< T > | findChildren (const QRegularExpression ®Exp, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
|
template<class T > |
QList< T > | findChildren (const QString &childName=QString (), Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
|
bool | inherits (const QString &className) const |
|
void | installEventFilter (QObject *filterObj) |
|
bool | isWidgetType () const |
|
bool | isWindowType () const |
|
void | killTimer (int id) |
|
const QMetaObject * | metaObject () const |
|
void | moveToThread (QThread *targetThread) |
|
QString | objectName () const |
|
QObject * | parent () const |
|
template<class T = QVariant> |
T | property (const QString &name) const |
|
void | removeEventFilter (QObject *obj) |
|
void | setObjectName (const QString &name) |
|
void | setParent (QObject *parent) |
|
bool | setProperty (const QString &name, const QVariant &value) |
|
bool | signalsBlocked () const |
|
int | startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer) |
|
QThread * | thread () const |
|
virtual | ~QPaintDevice () |
|
int | colorCount () const |
|
int | depth () const |
|
int | devicePixelRatio () const |
|
qreal | devicePixelRatioF () const |
|
int | height () const |
|
int | heightMM () const |
|
int | logicalDpiX () const |
|
int | logicalDpiY () const |
|
bool | paintingActive () const |
|
int | physicalDpiX () const |
|
int | physicalDpiY () const |
|
int | width () const |
|
int | widthMM () const |
|
|
using | RenderFlags = QFlags< RenderFlag > |
|
void | customContextMenuRequested (const QPoint &pos) |
|
void | windowIconChanged (const QIcon &icon) |
|
void | windowIconTextChanged (const QString &iconText) |
|
void | windowTitleChanged (const QString &title) |
|
void | destroyed (QObject *obj=nullptr) |
|
void | objectNameChanged (const QString &objectName) |
|
bool | close () |
|
void | hide () |
|
void | lower () |
|
void | raise () |
|
void | repaint () |
|
void | setDisabled (bool disable) |
|
void | setEnabled (bool enable) |
|
void | setFocus () |
|
void | setHidden (bool hidden) |
|
void | setStyleSheet (const QString &styleSheet) |
|
virtual void | setVisible (bool visible) |
|
void | setWindowModified (bool modified) |
|
void | setWindowTitle (const QString &title) |
|
void | show () |
|
void | showFullScreen () |
|
void | showMaximized () |
|
void | showMinimized () |
|
void | showNormal () |
|
void | update () |
|
void | deleteLater () |
|
static QWidget * | createWindowContainer (QWindow *window, QWidget *parent=nullptr, Qt::WindowFlags flags=Qt::EmptyFlag) |
|
static QWidget * | find (WId id) |
|
static QWidget * | keyboardGrabber () |
|
static QWidget * | mouseGrabber () |
|
static void | setTabOrder (QWidget *firstWidget, QWidget *secondWidget) |
|
static bool | connect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod, Qt::ConnectionType type=Qt::AutoConnection) |
|
static bool | connect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection, const QString &location=QString ()) |
|
static bool | connect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection) |
|
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn > |
static bool | connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...), Qt::ConnectionType type=Qt::AutoConnection) |
|
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T > |
static bool | connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotLambda, Qt::ConnectionType type=Qt::AutoConnection) |
|
static bool | disconnect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod) |
|
static bool | disconnect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod) |
|
static bool | disconnect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod) |
|
static bool | disconnect (const QObject *sender, std::nullptr_t, const QObject *receiver, std::nullptr_t) |
|
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn > |
static bool | disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...)) |
|
template<class Sender , class SignalClass , class... SignalArgs, class Receiver > |
static bool | disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, std::nullptr_t slotMethod=nullptr) |
|
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T > |
static bool | disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotMethod) |
|
static QMetaObject & | staticMetaObject () |
|
static QString | tr (const char *text, const char *comment=nullptr, std::optional< int > numArg=std::optional< int >()) |
|
void | updateMicroFocus () |
|
| acceptDrops |
|
| accessibleDescription |
|
| accessibleName |
|
| autoFillBackground |
|
| baseSize |
|
| childrenRect |
|
| childrenRegion |
|
| contextMenuPolicy |
|
| cursor |
|
| enabled |
|
| focus |
|
| focusPolicy |
|
| font |
|
| frameGeometry |
|
| frameSize |
|
| fullScreen |
|
| geometry |
|
| height |
|
| inputMethodHints |
|
| isActiveWindow |
|
| layoutDirection |
|
| locale |
|
| maximized |
|
| maximumHeight |
|
| maximumSize |
|
| maximumWidth |
|
| minimized |
|
| minimumHeight |
|
| minimumSize |
|
| minimumSizeHint |
|
| minimumWidth |
|
| modal |
|
| mouseTracking |
|
| normalGeometry |
|
| palette |
|
| pos |
|
| rect |
|
| size |
|
| sizeHint |
|
| sizeIncrement |
|
| sizePolicy |
|
| statusTip |
|
| styleSheet |
|
| toolTip |
|
| updatesEnabled |
|
| visible |
|
| whatsThis |
|
| width |
|
| windowFilePath |
|
| windowFlags |
|
| windowIcon |
|
| windowIconText |
|
| windowModality |
|
| windowModified |
|
| windowOpacity |
|
| windowTitle |
|
| x |
|
| y |
|
| objectName |
|
| QWidgetList |
|
| WId |
|
T | qobject_cast (QObject *object) |
|
| QObjectList |
|
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 does not 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.
{
origin = event->pos();
if (!rubberBand) {
rubberBand =
new QRubberBand(QRubberBand::Rectangle,
this);
}
rubberBand->show();
}
{
rubberBand->setGeometry(
QRect(origin, event->pos()).normalized());
}
{
rubberBand->hide();
}
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.
- See also
- QStyleOption::initFrom()