Qt:Документация 4.3.2/qrubberband
Материал из Wiki.crossplatform.ru
Внимание: Актуальная версия перевода документации находится здесь |
__NOTOC__
Главная · Все классы · Основные классы · Классы по группам · Модули · Функции |
[править] QRubberBand Class Reference
[модуль QtGui ]
The QRubberBand class provides a rectangle or line that can indicate a selection or a boundary. Далее...
#include <QRubberBand>
Наследует QWidget.
[править] Открытые типы
- enum Shape { Line, Rectangle }
[править] Открытые функции
- QRubberBand ( Shape s, QWidget * p = 0 )
- ~QRubberBand ()
- void move ( int x, int y )
- void move ( const QPoint & p )
- void resize ( int width, int height )
- void resize ( const QSize & size )
- void setGeometry ( const QRect & rect )
- void setGeometry ( int x, int y, int width, int height )
- Shape shape () const
- 201 свойство, унаследованное от QWidget
- 29 открытых функций, унаследованных от QObject
- 12 открытых функций, унаследованных от QPaintDevice
[править] Защищенные функции
- void initStyleOption ( QStyleOptionRubberBand * option ) const
- 38 защищенных функций, унаследованных от QWidget
- 7 защищенных функций, унаследованных от QObject
- 1 защищенная функция, унаследованных от QPaintDevice
[править] Дополнительные унаследованные члены
- 56 свойств, унаследованных от QWidget
- 1 свойство, унаследованное от QObject
- 19 открытых слотов, унаследованных от QWidget
- 1 открытый слот, унаследованный от QObject
- 1 сигнал, унаследованный от QWidget
- 1 сигнал, унаследованный от QObject
- 4 статических открытых члена, унаследованных от QWidget
- 5 статических открытых членов, унаследованных от QObject
- 1 защищенный слот, унаследованый от QWidget
[править] Подробное описание
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. Пример:
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.
[править] Описание типов
[править] enum QRubberBand::Shape
This enum specifies what shape a QRubberBand should have. This is a drawing hint that is passed down to the style system, and can be interpreted by each QStyle.
Константа | Значение | Описание |
---|---|---|
QRubberBand::Line | 0 | A QRubberBand can represent a vertical or horizontal line. Geometry is still given in rect() and the line will fill the given geometry on most styles. |
QRubberBand::Rectangle | 1 | A QRubberBand can represent a rectangle. Some styles will interpret this as a filled (often semi-transparent) rectangle, or a rectangular outline. |
[править] Описание функций-членов
[править] QRubberBand::QRubberBand ( Shape s, QWidget * p = 0 )
Constructs a rubber band of shape s, with parent p.
By default a rectangular rubber band (s 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.
[править] QRubberBand::~QRubberBand ()
Деструктор.
[править] void QRubberBand::initStyleOption ( QStyleOptionRubberBand * option ) const [protected]
Initialize option with the values from this QRubberBand. This method is useful for subclasses when they need a QStyleOptionRubberBand, but don't want to fill in all the information themselves.
See also QStyleOption::initFrom().
[править] void QRubberBand::move ( int x, int y )
Moves the rubberband to point (x, y).
See also resize().
[править] void QRubberBand::move ( const QPoint & p )
Эта перегруженная функция предоставлена для удобства.
Moves the rubberband to point p.
See also resize().
[править] void QRubberBand::resize ( int width, int height )
Resizes the rubberband so that its width is width, and its height is height.
See also move().
[править] void QRubberBand::resize ( const QSize & size )
Эта перегруженная функция предоставлена для удобства.
Resizes the rubberband so that its new size is size.
See also move().
[править] void QRubberBand::setGeometry ( const QRect & rect )
Sets the geometry of the rubber band to rect, specified in the coordinate system of its parent widget.
See also QWidget::geometry.
[править] void QRubberBand::setGeometry ( int x, int y, int width, int height )
Эта перегруженная функция предоставлена для удобства.
Sets the geometry of the rubberband to the rectangle whose top-left corner lies at the point (x, y), and with dimensions specified by width and height. The geometry is specified in the parent widget's coordinate system.
[править] Shape QRubberBand::shape () const
Returns the shape of this rubber band. The shape can only be set upon construction.
Copyright © 2007 Trolltech | Trademarks | Qt 4.3.2
|