CopperSpice API
1.9.2
|
The QAbstractScrollArea widget provides a scrolling area with on-demand scroll bars. More...
Public Methods | |
QAbstractScrollArea (QWidget *parent=nullptr) | |
~QAbstractScrollArea () | |
void | addScrollBarWidget (QWidget *widget, Qt::Alignment alignment) |
QWidget * | cornerWidget () const |
QScrollBar * | horizontalScrollBar () const |
Qt::ScrollBarPolicy | horizontalScrollBarPolicy () const |
QSize | maximumViewportSize () const |
QSize | minimumSizeHint () const override |
QWidgetList | scrollBarWidgets (Qt::Alignment alignment) |
void | setCornerWidget (QWidget *widget) |
void | setHorizontalScrollBar (QScrollBar *scrollBar) |
void | setHorizontalScrollBarPolicy (Qt::ScrollBarPolicy policy) |
void | setSizeAdjustPolicy (SizeAdjustPolicy policy) |
virtual void | setupViewport (QWidget *viewport) |
void | setVerticalScrollBar (QScrollBar *scrollBar) |
void | setVerticalScrollBarPolicy (Qt::ScrollBarPolicy policy) |
void | setViewport (QWidget *widget) |
SizeAdjustPolicy | sizeAdjustPolicy () const |
QSize | sizeHint () const override |
QScrollBar * | verticalScrollBar () const |
Qt::ScrollBarPolicy | verticalScrollBarPolicy () const |
QWidget * | viewport () const |
Public Methods inherited from QFrame | |
QFrame (QWidget *parent=nullptr, Qt::WindowFlags flags=Qt::EmptyFlag) | |
~QFrame () | |
QRect | frameRect () const |
Shadow | frameShadow () const |
Shape | frameShape () const |
int | frameStyle () const |
int | frameWidth () const |
int | lineWidth () const |
int | midLineWidth () const |
void | setFrameRect (const QRect &rect) |
void | setFrameShadow (Shadow value) |
void | setFrameShape (Shape value) |
void | setFrameStyle (int style) |
void | setLineWidth (int width) |
void | setMidLineWidth (int width) |
QSize | sizeHint () const override |
Public Methods inherited from QWidget | |
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 |
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 |
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 |
Public Methods inherited from QObject | |
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 |
Public Methods inherited from QPaintDevice | |
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 |
Protected Methods | |
void | contextMenuEvent (QContextMenuEvent *event) override |
void | dragEnterEvent (QDragEnterEvent *event) override |
void | dragLeaveEvent (QDragLeaveEvent *event) override |
void | dragMoveEvent (QDragMoveEvent *event) override |
void | dropEvent (QDropEvent *event) override |
bool | event (QEvent *event) override |
void | keyPressEvent (QKeyEvent *event) override |
void | mouseDoubleClickEvent (QMouseEvent *event) override |
void | mouseMoveEvent (QMouseEvent *event) override |
void | mousePressEvent (QMouseEvent *event) override |
void | mouseReleaseEvent (QMouseEvent *event) override |
void | paintEvent (QPaintEvent *event) override |
void | resizeEvent (QResizeEvent *event) override |
virtual void | scrollContentsBy (int dx, int dy) |
void | setViewportMargins (const QMargins &margins) |
void | setViewportMargins (int left, int top, int right, int bottom) |
virtual bool | viewportEvent (QEvent *event) |
QMargins | viewportMargins () const |
virtual QSize | viewportSizeHint () const |
void | wheelEvent (QWheelEvent *event) override |
Protected Methods inherited from QFrame | |
void | changeEvent (QEvent *event) override |
void | drawFrame (QPainter *painter) |
bool | event (QEvent *event) override |
void | initStyleOption (QStyleOptionFrame *option) const |
void | paintEvent (QPaintEvent *event) override |
Protected Methods inherited from QWidget | |
virtual void | actionEvent (QActionEvent *event) |
virtual void | closeEvent (QCloseEvent *event) |
void | create (WId window=0, bool initializeWindow=true, bool destroyOldWindow=true) |
void | destroy (bool destroyWindow=true, bool destroySubWindows=true) |
virtual void | enterEvent (QEvent *event) |
bool | event (QEvent *event) override |
virtual void | focusInEvent (QFocusEvent *event) |
bool | focusNextChild () |
virtual bool | focusNextPrevChild (bool next) |
virtual void | focusOutEvent (QFocusEvent *event) |
bool | focusPreviousChild () |
virtual void | hideEvent (QHideEvent *event) |
void | initPainter (QPainter *painter) const override |
virtual void | inputMethodEvent (QInputMethodEvent *event) |
virtual void | keyReleaseEvent (QKeyEvent *event) |
virtual void | leaveEvent (QEvent *event) |
int | metric (PaintDeviceMetric metric) const override |
virtual void | moveEvent (QMoveEvent *event) |
virtual bool | nativeEvent (const QByteArray &eventType, void *message, long *result) |
virtual void | showEvent (QShowEvent *event) |
virtual void | tabletEvent (QTabletEvent *event) |
Protected Methods inherited from QObject | |
virtual void | childEvent (QChildEvent *event) |
virtual void | connectNotify (const QMetaMethod &signalMethod) const |
virtual void | customEvent (QEvent *event) |
virtual void | disconnectNotify (const QMetaMethod &signalMethod) const |
bool | isSignalConnected (const QMetaMethod &signalMethod) const |
int | receivers (const QString &signal) const |
QObject * | sender () const |
int | senderSignalIndex () const |
virtual void | timerEvent (QTimerEvent *event) |
Protected Methods inherited from QPaintDevice | |
QPaintDevice () | |
Additional Inherited Members | |
Public Typedefs inherited from QWidget | |
using | RenderFlags = QFlags< RenderFlag > |
Public Types inherited from QFrame | |
enum | Shadow |
enum | Shape |
enum | StyleMask |
Public Types inherited from QWidget | |
enum | RenderFlag |
Public Types inherited from QPaintDevice | |
enum | PaintDeviceMetric |
Public Signals inherited from QWidget | |
void | customContextMenuRequested (const QPoint &pos) |
void | windowIconChanged (const QIcon &icon) |
void | windowIconTextChanged (const QString &iconText) |
void | windowTitleChanged (const QString &title) |
Public Signals inherited from QObject | |
void | destroyed (QObject *obj=nullptr) |
void | objectNameChanged (const QString &objectName) |
Public Slots inherited from QWidget | |
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 () |
Public Slots inherited from QObject | |
void | deleteLater () |
Static Public Methods inherited from QWidget | |
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 Public Methods inherited from QObject | |
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 >()) |
Protected Slots inherited from QWidget | |
void | updateMicroFocus () |
Related Functions inherited from QWidget | |
QWidgetList | |
WId | |
Related Functions inherited from QObject | |
T | qobject_cast (QObject *object) |
QObjectList | |
The QAbstractScrollArea widget provides a scrolling area with on-demand scroll bars. This class is a low-level abstraction of a scrolling area. The area provides a central widget called the viewport, in which the contents of the area is to be scrolled (i.e, the visible parts of the contents are rendered in the viewport).
Next to the viewport is a vertical scroll bar, and below is a horizontal scroll bar. When all of the area contents fits in the viewport, each scroll bar can be either visible or hidden depending on the scroll bar's Qt::ScrollBarPolicy. When a scroll bar is hidden, the viewport expands in order to cover all available space. When a scroll bar becomes visible again, the viewport shrinks in order to make room for the scroll bar.
It is possible to reserve a margin area around the viewport, see setViewportMargins(). The feature is mostly used to place a QHeaderView widget above or beside the scrolling area. Subclasses of QAbstractScrollArea should implement margins.
When inheriting QAbstractScrollArea, you need to do the following:
viewport->update()
to update the contents of the viewport instead of update() as all painting operations take place on the viewport. With a scroll bar policy of Qt::ScrollBarAsNeeded (the default), QAbstractScrollArea shows scroll bars when they provide a non-zero scrolling range, and hides them otherwise.
The scroll bars and viewport should be updated whenever the viewport receives a resize event or the size of the contents changes. The viewport also needs to be updated when the scroll bars values change. The initial values of the scroll bars are often set when the area receives new contents.
We give a simple example, in which we have implemented a scroll area that can scroll any QWidget. We make the widget a child of the viewport; this way, we do not have to calculate which part of the widget to draw but can simply move the widget with QWidget::move(). When the area contents or the viewport size changes, we do the following:
When the scroll bars change value, we need to update the widget position.
In order to track scroll bar movements, reimplement the virtual function scrollContentsBy(). In order to fine-tune scrolling behavior, connect to a scroll bar's QAbstractSlider::actionTriggered() signal and adjust the QAbstractSlider::sliderPosition as you wish.
For convenience, QAbstractScrollArea makes all viewport events available in the virtual viewportEvent() handler. QWidget's specialized handlers are remapped to viewport events in the cases where this makes sense. The remapped specialized handlers are: paintEvent(), mousePressEvent(), mouseReleaseEvent(), mouseDoubleClickEvent(), mouseMoveEvent(), wheelEvent(), dragEnterEvent(), dragMoveEvent(), dragLeaveEvent(), dropEvent(), contextMenuEvent(), and resizeEvent().
QScrollArea, which inherits QAbstractScrollArea, provides smooth scrolling for any QWidget (i.e., the widget is scrolled pixel by pixel). You only need to subclass QAbstractScrollArea if you need more specialized behavior. This is, for instance, true if the entire contents of the area is not suitable for being drawn on a QWidget or if you do not want smooth scrolling.
|
explicit |
Constructs a viewport. The parent argument is sent to the QWidget constructor.
QAbstractScrollArea::~QAbstractScrollArea | ( | ) |
Destroys the viewport.
void QAbstractScrollArea::addScrollBarWidget | ( | QWidget * | widget, |
Qt::Alignment | alignment | ||
) |
Adds widget as a scroll bar widget in the location specified by alignment.
Scroll bar widgets are shown next to the horizontal or vertical scroll bar, and can be placed on either side of it. If you want the scroll bar widgets to be always visible, set the scrollBarPolicy for the corresponding scroll bar to AlwaysOn
.
alignment must be one of Qt::Alignleft and Qt::AlignRight, which maps to the horizontal scroll bar, or Qt::AlignTop and Qt::AlignBottom, which maps to the vertical scroll bar.
A scroll bar widget can be removed by either re-parenting the widget or deleting it. It is also possible to hide a widget with QWidget::hide()
The scroll bar widget will be resized to fit the scroll bar geometry for the current style. The following describes the case for scroll bar widgets on the horizontal scroll bar:
The height of the widget will be set to match the height of the scroll bar. To control the width of the widget, use QWidget::setMinimumWidth and QWidget::setMaximumWidth, or implement QWidget::sizeHint() and set a horizontal size policy. If you want a square widget, call QStyle::pixelMetric(QStyle::PM_ScrollBarExtent) and set the width to this value.
|
overrideprotectedvirtual |
This event handler can be reimplemented in a subclass to receive context menu events for the viewport() widget. The event is passed in event.
Reimplemented from QWidget::contextMenuEvent()
Reimplemented in QTextEdit::contextMenuEvent(), QPlainTextEdit::contextMenuEvent()
QWidget * QAbstractScrollArea::cornerWidget | ( | ) | const |
Returns the widget in the corner between the two scroll bars. By default, no corner widget is present.
|
overrideprotectedvirtual |
This event handler can be reimplemented in a subclass to receive drag events for the viewport() widget. The event is passed in event.
Reimplemented from QWidget::dragEnterEvent()
Reimplemented in QTextEdit::dragEnterEvent(), QPlainTextEdit::dragEnterEvent()
|
overrideprotectedvirtual |
This event handler can be reimplemented in a subclass to receive drag leave events for the viewport() widget. The event is passed in event.
Reimplemented from QWidget::dragLeaveEvent()
Reimplemented in QTextEdit::dragLeaveEvent(), QPlainTextEdit::dragLeaveEvent()
|
overrideprotectedvirtual |
This event handler can be reimplemented in a subclass to receive drag move events or the viewport() widget. The event is passed in event.
Reimplemented from QWidget::dragMoveEvent()
Reimplemented in QTextEdit::dragMoveEvent(), QPlainTextEdit::dragMoveEvent()
|
overrideprotectedvirtual |
This event handler can be reimplemented in a subclass to receive drop events for the viewport() widget. The event is passed in event.
Reimplemented from QWidget::dropEvent()
Reimplemented in QTextEdit::dropEvent(), QPlainTextEdit::dropEvent()
|
overrideprotected |
This is the main event handler for the QAbstractScrollArea widget, not the scrolling area viewport(). The specified event is a general event object that may need to be cast to the appropriate class depending on its type.
QScrollBar * QAbstractScrollArea::horizontalScrollBar | ( | ) | const |
Returns the horizontal scroll bar.
Qt::ScrollBarPolicy QAbstractScrollArea::horizontalScrollBarPolicy | ( | ) | const |
Returns the value of the property.
|
overrideprotectedvirtual |
Called with key event when a key press occurs. Handles PageUp, PageDown, Up, Down, Left, and Right, and ignores all other key presses.
Reimplemented from QWidget::keyPressEvent()
Reimplemented in QTextEdit::keyPressEvent(), QPlainTextEdit::keyPressEvent(), QTextBrowser::keyPressEvent()
QSize QAbstractScrollArea::maximumViewportSize | ( | ) | const |
Returns the size of the viewport as if the scroll bars had no valid scrolling range.
|
overridevirtual |
Reimplemented from QWidget::minimumSizeHint()
Reimplemented in QMdiArea::minimumSizeHint()
|
overrideprotectedvirtual |
This event handler can be reimplemented in a subclass to receive mouse double click events for the viewport() widget. The event is passed in event.
Reimplemented from QWidget::mouseDoubleClickEvent()
Reimplemented in QTextEdit::mouseDoubleClickEvent(), QPlainTextEdit::mouseDoubleClickEvent()
|
overrideprotectedvirtual |
This event handler can be reimplemented in a subclass to receive mouse move events for the viewport() widget. The event is passed in event.
Reimplemented from QWidget::mouseMoveEvent()
Reimplemented in QTextEdit::mouseMoveEvent(), QPlainTextEdit::mouseMoveEvent(), QTextBrowser::mouseMoveEvent()
|
overrideprotectedvirtual |
This event handler can be reimplemented in a subclass to receive mouse press events for the viewport() widget. The event is passed in event.
Reimplemented from QWidget::mousePressEvent()
Reimplemented in QTextEdit::mousePressEvent(), QPlainTextEdit::mousePressEvent(), QTextBrowser::mousePressEvent()
|
overrideprotectedvirtual |
This event handler can be reimplemented in a subclass to receive mouse release events for the viewport() widget. The event is passed in event.
Reimplemented from QWidget::mouseReleaseEvent()
Reimplemented in QTextEdit::mouseReleaseEvent(), QPlainTextEdit::mouseReleaseEvent(), QTextBrowser::mouseReleaseEvent()
|
overrideprotectedvirtual |
This event handler can be reimplemented in a subclass to receive paint events for the viewport() widget. The event is passed in event.
If you open a painter, make sure to open it on the viewport().
Reimplemented from QWidget::paintEvent()
Reimplemented in QMdiArea::paintEvent(), QTextEdit::paintEvent(), QPlainTextEdit::paintEvent(), QTextBrowser::paintEvent()
|
overrideprotectedvirtual |
This event handler can be reimplemented in a subclass to receive resize events for the viewport() widget. The event is passed in event.
When resizeEvent() is called, the viewport already has its new geometry: Its new size is accessible through the QResizeEvent::size() function, and the old size through QResizeEvent::oldSize().
Reimplemented from QWidget::resizeEvent()
Reimplemented in QMdiArea::resizeEvent(), QTextEdit::resizeEvent(), QPlainTextEdit::resizeEvent(), QScrollArea::resizeEvent()
QWidgetList QAbstractScrollArea::scrollBarWidgets | ( | Qt::Alignment | alignment | ) |
Returns a list of the currently set scroll bar widgets. The alignment can be any combination of the four location flags.
|
protectedvirtual |
This virtual handler is called when the scroll bars are moved by dx, dy, and consequently the viewport's contents should be scrolled accordingly.
The default implementation simply calls update() on the entire viewport(). Subclasses can reimplement this handler for optimization purposes, or as with QScrollArea to move a contents widget. The parameters dx and dy are there for convenience, so that the class knows how much should be scrolled. You may ignore these values and scroll directly to the position the scroll bars indicate.
Calling this method in order to scroll programmatically is an error, use the scroll bars instead (e.g. by calling QScrollBar::setValue() directly).
Reimplemented in QTextEdit::scrollContentsBy(), QPlainTextEdit::scrollContentsBy(), QGraphicsView::scrollContentsBy(), QHeaderView::scrollContentsBy(), QListView::scrollContentsBy(), QTreeView::scrollContentsBy(), QMdiArea::scrollContentsBy(), QTableView::scrollContentsBy(), QColumnView::scrollContentsBy(), QScrollArea::scrollContentsBy()
void QAbstractScrollArea::setCornerWidget | ( | QWidget * | widget | ) |
Sets the widget in the corner between the two scroll bars to be widget. You will probably also want to set at least one of the scroll bar modes to AlwaysOn
. Passing nullptr shows no widget in the corner. Any previous corner widget will be hidden.
All widgets passed to this method will be deleted by the scroll area when it is destroyed, unless you separately reparent the widget after setting some other corner widget. Any new widgets should have no current parent.
By default no corner widget is present.
void QAbstractScrollArea::setHorizontalScrollBar | ( | QScrollBar * | scrollBar | ) |
Replaces the existing horizontal scroll bar with scrollBar, and sets all the former scroll bar's slider properties on the new scroll bar. The former scroll bar is then deleted.
QAbstractScrollArea already provides horizontal and vertical scroll bars by default. You can call this function to replace the default horizontal scroll bar with your own custom scroll bar.
void QAbstractScrollArea::setHorizontalScrollBarPolicy | ( | Qt::ScrollBarPolicy | policy | ) |
Sets the value of the property to policy.
void QAbstractScrollArea::setSizeAdjustPolicy | ( | SizeAdjustPolicy | policy | ) |
Sets the value of the property to policy.
|
virtual |
This slot is called by QAbstractScrollArea after setViewport(viewport) has been called. Reimplement this function in a subclass of QAbstractScrollArea to initialize the new viewport before it is used.
void QAbstractScrollArea::setVerticalScrollBar | ( | QScrollBar * | scrollBar | ) |
Replaces the existing vertical scroll bar with scrollBar, and sets all the former scroll bar's slider properties on the new scroll bar. The former scroll bar is then deleted.
QAbstractScrollArea already provides vertical and horizontal scroll bars by default. You can call this method to replace the default vertical scroll bar with your own custom scroll bar.
void QAbstractScrollArea::setVerticalScrollBarPolicy | ( | Qt::ScrollBarPolicy | policy | ) |
Sets the value of the property to policy.
void QAbstractScrollArea::setViewport | ( | QWidget * | widget | ) |
Sets the viewport to be the given widget. The QAbstractScrollArea will take ownership of the given widget. If widget is a nullptr QAbstractScrollArea will assign a new QWidget instance for the viewport.
|
protected |
Sets margins around the scrolling area. This is useful for applications such as spreadsheets with "locked" rows and columns. The margin space is left blank to provide an area for widgets. By default all margins are zero.
|
protected |
Sets the margins around the scrolling area to left, top, right, and bottom. This is useful for applications such as spreadsheets with "locked" rows and columns. The margin space is left blank to provide an area for widgets. By default all margins are zero.
This method is called by QTreeView and QTableView and must be implemented in any class which inherits from QAbstractScrollArea.
SizeAdjustPolicy QAbstractScrollArea::sizeAdjustPolicy | ( | ) | const |
Returns the value of the property.
|
overridevirtual |
Reimplemented from QWidget::sizeHint()
Reimplemented in QMdiArea::sizeHint(), QScrollArea::sizeHint()
QScrollBar * QAbstractScrollArea::verticalScrollBar | ( | ) | const |
Returns the vertical scroll bar.
Qt::ScrollBarPolicy QAbstractScrollArea::verticalScrollBarPolicy | ( | ) | const |
Returns the value of the property.
QWidget * QAbstractScrollArea::viewport | ( | ) | const |
Returns the viewport widget. Use the QScrollArea::widget() method to retrieve the contents of the viewport widget.
|
protectedvirtual |
The main event handler for the scrolling area the viewport() widget. It handles the event specified, and can be called by subclasses to provide reasonable default behavior. Returns true to indicate to the event system that the event has been handled, and needs no further processing, otherwise returns false to indicate that the event should be propagated further.
You can reimplement this method in a subclass, but we recommend using one of the specialized event handlers instead.
Specialized handlers for viewport events are: paintEvent(), mousePressEvent(), mouseReleaseEvent(), mouseDoubleClickEvent(), mouseMoveEvent(), wheelEvent(), dragEnterEvent(), dragMoveEvent(), dragLeaveEvent(), dropEvent(), contextMenuEvent(), and resizeEvent().
Reimplemented in QAbstractItemView::viewportEvent(), QGraphicsView::viewportEvent(), QHeaderView::viewportEvent(), QTreeView::viewportEvent(), QMdiArea::viewportEvent()
|
protected |
Returns the value of the property.
|
protectedvirtual |
Returns the value of the property.
Reimplemented in QAbstractItemView::viewportSizeHint(), QListView::viewportSizeHint(), QTreeView::viewportSizeHint(), QTableView::viewportSizeHint(), QScrollArea::viewportSizeHint()
|
overrideprotectedvirtual |
This event handler can be reimplemented in a subclass to receive wheel events for the viewport() widget. The event is passed in event.
Reimplemented from QWidget::wheelEvent()
Reimplemented in QTextEdit::wheelEvent(), QPlainTextEdit::wheelEvent()
|
This property holds the policy for the horizontal scroll bar. The default policy is Qt::ScrollBarAsNeeded.
Properties | Class Methods |
---|---|
read | horizontalScrollBarPolicy |
write | setHorizontalScrollBarPolicy |
|
This property holds the policy for the vertical scroll bar. The default policy is Qt::ScrollBarAsNeeded.
Properties | Class Methods |
---|---|
read | verticalScrollBarPolicy |
write | setVerticalScrollBarPolicy |