The Q3ScrollView 小部件提供带按需滚动条的卷动区域。 更多...
| 头: | #include <Q3ScrollView> |
| 继承: | Q3Frame |
| 继承者: | Q3CanvasView , Q3GridView , Q3IconView , Q3ListBox , Q3ListView , Q3Table ,和 Q3TextEdit |
| enum | ResizePolicy { Default, Manual, AutoOne, AutoOneFit } |
| enum | ScrollBarMode { Auto, AlwaysOff, AlwaysOn } |
|
|
| Q3ScrollView (QWidget * parent = 0, const char * name = 0, Qt::WindowFlags f = 0) | |
| ~Q3ScrollView () | |
| virtual void | addChild (QWidget * child , int x = 0, int y = 0) |
| int | bottomMargin () const |
| int | childX (QWidget * child ) |
| int | childY (QWidget * child ) |
| QWidget * | clipper () const |
| int | contentsHeight () const |
| void | contentsToViewport (int x , int y , int & vx , int & vy ) const |
| QPoint | contentsToViewport (const QPoint & p ) const |
| int | contentsWidth () const |
| int | contentsX () const |
| int | contentsY () const |
| QWidget * | cornerWidget () const |
| bool | dragAutoScroll () const |
| void | enableClipper (bool y ) |
| ScrollBarMode | hScrollBarMode () const |
| bool | hasStaticBackground () const |
| QScrollBar * | horizontalScrollBar () const |
| bool | isHorizontalSliderPressed () |
| bool | isVerticalSliderPressed () |
| int | leftMargin () const |
| virtual void | moveChild (QWidget * child , int x , int y ) |
| void | removeChild (QWidget * child ) |
| void | repaintContents (int x , int y , int w , int h , bool erase = true) |
| void | repaintContents (const QRect & r , bool erase = true) |
| void | repaintContents (bool erase = true) |
| ResizePolicy | resizePolicy () const |
| int | rightMargin () const |
| virtual void | setCornerWidget (QWidget * corner ) |
| virtual void | setDragAutoScroll (bool b ) |
| virtual void | setHScrollBarMode (ScrollBarMode) |
| virtual void | setMargins (int left , int top , int right , int bottom ) |
| virtual void | setResizePolicy (ResizePolicy) |
| void | setStaticBackground (bool y ) |
| virtual void | setVScrollBarMode (ScrollBarMode) |
| int | topMargin () const |
| void | updateContents (int x , int y , int w , int h ) |
| void | updateContents (const QRect & r ) |
| void | updateContents () |
| ScrollBarMode | vScrollBarMode () const |
| QScrollBar * | verticalScrollBar () const |
| QWidget * | viewport () const |
| QSize | viewportSize (int x , int y ) const |
| void | viewportToContents (int vx , int vy , int & x , int & y ) const |
| QPoint | viewportToContents (const QPoint & vp ) const |
| int | visibleHeight () const |
| int | visibleWidth () const |
| virtual QSize | minimumSizeHint () const |
| virtual void | setVisible (bool visible ) |
| virtual QSize | sizeHint () const |
| void | center (int x , int y ) |
| void | center (int x , int y , float xmargin , float ymargin ) |
| void | ensureVisible (int x , int y ) |
| void | ensureVisible (int x , int y , int xmargin , int ymargin ) |
| virtual void | resizeContents (int w , int h ) |
| void | scrollBy (int dx , int dy ) |
| virtual void | setContentsPos (int x , int y ) |
| void | updateScrollBars () |
| void | contentsMoving (int x , int y ) |
| void | horizontalSliderPressed () |
| void | horizontalSliderReleased () |
| void | verticalSliderPressed () |
| void | verticalSliderReleased () |
| virtual void | contentsContextMenuEvent (QContextMenuEvent * e ) |
| virtual void | contentsDragEnterEvent (QDragEnterEvent * event ) |
| virtual void | contentsDragLeaveEvent (QDragLeaveEvent * event ) |
| virtual void | contentsDragMoveEvent (QDragMoveEvent * event ) |
| virtual void | contentsDropEvent (QDropEvent * event ) |
| virtual void | contentsMouseDoubleClickEvent (QMouseEvent * e ) |
| virtual void | contentsMouseMoveEvent (QMouseEvent * e ) |
| virtual void | contentsMousePressEvent (QMouseEvent * e ) |
| virtual void | contentsMouseReleaseEvent (QMouseEvent * e ) |
| virtual void | contentsWheelEvent (QWheelEvent * e ) |
| virtual void | drawContents (QPainter * p , int clipx , int clipy , int clipw , int cliph ) |
| virtual void | drawContentsOffset (QPainter * p , int offsetx , int offsety , int clipx , int clipy , int clipw , int cliph ) |
| virtual void | setHBarGeometry (QScrollBar & hbar , int x , int y , int w , int h ) |
| virtual void | setVBarGeometry (QScrollBar & vbar , int x , int y , int w , int h ) |
| virtual void | viewportPaintEvent (QPaintEvent * pe ) |
| virtual void | viewportResizeEvent (QResizeEvent * event ) |
| virtual void | contextMenuEvent (QContextMenuEvent * e ) |
| virtual bool | eventFilter (QObject * obj , QEvent * e ) |
| virtual bool | focusNextPrevChild (bool next ) |
| virtual void | frameChanged () |
| virtual void | mouseDoubleClickEvent (QMouseEvent * e ) |
| virtual void | mouseMoveEvent (QMouseEvent * e ) |
| virtual void | mousePressEvent (QMouseEvent * e ) |
| virtual void | mouseReleaseEvent (QMouseEvent * e ) |
| virtual void | resizeEvent (QResizeEvent * event ) |
| virtual void | wheelEvent (QWheelEvent * e ) |
The Q3ScrollView 小部件提供带按需滚动条的卷动区域。
The Q3ScrollView is a large canvas - potentially larger than the coordinate system normally supported by the underlying window system. This is important because it is quite easy to go beyond these limitations (e.g. many web pages are more than 32000 pixels high). Additionally, the Q3ScrollView can have QWidgets positioned on it that scroll around with the drawn content. These sub-widgets can also have positions outside the normal coordinate range (but they are still limited in size).
To provide content for the widget, inherit from Q3ScrollView , reimplement drawContents () and use resizeContents () to set the size of the viewed area. Use addChild () 和 moveChild () to position widgets on the view.
要使用 Q3ScrollView effectively it is important to understand its widget structure in the three styles of use: a single large child widget, a large panning area with some widgets and a large panning area with many widgets.
The first, simplest usage of Q3ScrollView (depicted above), is appropriate for scrolling areas that are never more than about 4000 pixels in either dimension (this is about the maximum reliable size on X11 servers). In this usage, you just make one large child in the Q3ScrollView . The child should be a child of the viewport () of the scrollview and be added with addChild ():
Q3ScrollView* sv = new Q3ScrollView(...); QWidget *widget = new QWidget(sv->viewport()); QVBoxLayout *layout = new QVBoxLayout(widget); addChild(widget);
You can go on to add arbitrary child widgets to the single child in the scrollview as you would with any widget:
QLabel* child1 = new QLabel("CHILD", widget); QLabel* child2 = new QLabel("CHILD", widget); QLabel* child3 = new QLabel("CHILD", widget); layout->addWidget(child1); layout->addWidget(child2); layout->addWidget(child3); ...
Here the Q3ScrollView has four children: the viewport (), verticalScrollBar (), horizontalScrollBar () and a small cornerWidget ()。 viewport () has one child: the QWidget 。 QWidget has the three QLabel objects as child widgets. When the view is scrolled, the QWidget is moved; its children move with it as child widgets normally do.
The second usage of Q3ScrollView (depicted above) is appropriate when few, if any, widgets are on a very large scrolling area that is potentially larger than 4000 pixels in either dimension. In this usage you call resizeContents () to set the size of the area and reimplement drawContents () to paint the contents. You may also add some widgets by making them children of the viewport () and adding them with addChild () (this is the same as the process for the single large widget in the previous example):
Q3ScrollView* sv = new Q3ScrollView(...); QLabel* child1 = new QLabel("CHILD", sv->viewport()); sv->addChild(child1); QLabel* child2 = new QLabel("CHILD", sv->viewport()); sv->addChild(child2); QLabel* child3 = new QLabel("CHILD", sv->viewport()); sv->addChild(child3);
在这里, Q3ScrollView has the same four children: the viewport (), verticalScrollBar (), horizontalScrollBar () and a small cornerWidget ()。 viewport () has the three QLabel objects as child widgets. When the view is scrolled, the scrollview moves the child widgets individually.
The final usage of Q3ScrollView (depicted above) is appropriate when many widgets are on a very large scrolling area that is potentially larger than 4000 pixels in either dimension. In this usage you call resizeContents () to set the size of the area and reimplement drawContents () to paint the contents. You then call enableClipper (true) and add widgets, again by making them children of the viewport (), and adding them with addChild ():
Q3ScrollView* sv = new Q3ScrollView(...); sv->enableClipper(true); QLabel* child1 = new QLabel("CHILD", sv->viewport()); sv->addChild(child1); QLabel* child2 = new QLabel("CHILD", sv->viewport()); sv->addChild(child2); QLabel* child3 = new QLabel("CHILD", sv->viewport()); sv->addChild(child3);
在这里, Q3ScrollView has four children: the clipper () (not the viewport () this time), the verticalScrollBar (), horizontalScrollBar () and a small cornerWidget ()。 clipper () has one child: the viewport ()。 viewport () has the same three labels as child widgets. When the view is scrolled the viewport () is moved; its children move with it as child widgets normally do.
Normally you will use the first or third method if you want any child widgets in the view.
Note that the widget you see in the scrolled area is the viewport () widget, not the Q3ScrollView itself. So to turn mouse tracking on, for example, use viewport ()-> setMouseTracking (true)。
To enable drag-and-drop, you would setAcceptDrops (true) on the Q3ScrollView (because drag-and-drop events propagate to the parent). But to work out the logical position in the view, you would need to map the drop co-ordinate from being relative to the Q3ScrollView to being relative to the contents; use the function viewportToContents () for this.
To handle mouse events on the scrolling area, subclass scrollview as you would subclass other widgets, but rather than reimplementing mousePressEvent (), reimplement contentsMousePressEvent () instead. The contents specific event handlers provide translated events in the coordinate system of the scrollview. If you reimplement mousePressEvent (), you'll get called only when part of the Q3ScrollView is clicked: and the only such part is the "corner" (if you don't set a cornerWidget ()) and the frame; everything else is covered up by the viewport, clipper or scroll bars.
When you construct a Q3ScrollView , some of the window flags apply to the viewport () instead of being sent to the QWidget constructor for the Q3ScrollView .
WNoAutoErase|WStaticContents
because the widget draws all pixels itself, and when its size increases, it only needs a paint event for the new part because the old part remains unchanged.
WNoAutoErase
(in addition to
WStaticContents
) so that the window system background does not flash in and out during scrolling.
WNoAutoErase
and repaint itself line by line to get a less-flickery resizing. If the widget is in a mode in which no text justification can take place, it might use
WStaticContents
too, so that it would only get a repaint for the newly visible parts.
Child widgets may be moved using addChild () 或 moveChild ()。使用 childX () 和 childY () to get the position of a child widget.
A widget may be placed in the corner between the vertical and horizontal scroll bars with setCornerWidget (). You can get access to the scroll bars using horizontalScrollBar () 和 verticalScrollBar (), and to the viewport with viewport (). The scroll view can be scrolled using scrollBy (), ensureVisible (), setContentsPos () 或 center ().
The visible area is given by visibleWidth () 和 visibleHeight (), and the contents area by contentsWidth () 和 contentsHeight (). The contents may be repainted using one of the repaintContents () 或 updateContents () 函数。
Coordinate conversion is provided by contentsToViewport () 和 viewportToContents ().
The contentsMoving () signal is emitted just before the contents are moved to a new position.
警告:
Q3ScrollView
currently does not erase the background when resized, i.e. you must always clear the background manually in scrollview subclasses. This will change in a future version of Qt and we recommend specifying the
WNoAutoErase
flag explicitly.
This enum type is used to control a Q3ScrollView 's reaction to resize events.
| 常量 | 值 | 描述 |
|---|---|---|
Q3ScrollView::Default
|
0
|
the
Q3ScrollView
selects one of the other settings automatically when it has to. In this version of Qt,
Q3ScrollView
changes to
Manual
if you resize the contents with
resizeContents
() and to
AutoOne
if a child is added.
|
Q3ScrollView::Manual
|
1
|
the contents stays the size set by resizeContents (). |
Q3ScrollView::AutoOne
|
2
|
if there is only one child widget the contents stays the size of that widget. Otherwise the behavior is undefined. |
Q3ScrollView::AutoOneFit
|
3
|
if there is only one child widget the contents stays the size of that widget's sizeHint (). If the scrollview is resized larger than the child's sizeHint (), the child will be resized to fit. If there is more than one child, the behavior is undefined. |
此枚举类型描述各种模式为 Q3ScrollView 的滚动条。
| 常量 | 值 | 描述 |
|---|---|---|
Q3ScrollView::Auto
|
0
|
Q3ScrollView 展示滚动条当要拟合内容太大时,否则不展示。这为默认。 |
Q3ScrollView::AlwaysOff
|
1
|
Q3ScrollView 从不展示滚动条。 |
Q3ScrollView::AlwaysOn
|
2
|
Q3ScrollView always shows a scroll bar. |
(水平和垂直滚动条的模式是独立的。)
This property holds the height of the contents area.
访问函数:
| int | contentsHeight () const |
This property holds the width of the contents area.
访问函数:
| int | contentsWidth () const |
This property holds the X coordinate of the contents that are at the left edge of the viewport.
访问函数:
| int | contentsX () const |
This property holds the Y coordinate of the contents that are at the top edge of the viewport.
访问函数:
| int | contentsY () const |
This property holds whether autoscrolling in drag move events is enabled.
若此特性被设为 true (默认), Q3ScrollView automatically scrolls the contents in drag move events if the user moves the cursor close to a border of the view. Of course this works only if the viewport accepts drops. Specifying false disables this autoscroll feature.
访问函数:
| bool | dragAutoScroll () const |
| virtual void | setDragAutoScroll (bool b ) |
This property holds the mode for the horizontal scroll bar.
默认模式为 Q3ScrollView::Auto .
访问函数:
| ScrollBarMode | hScrollBarMode () const |
| virtual void | setHScrollBarMode (ScrollBarMode) |
另请参阅 vScrollBarMode .
This property holds the resize policy.
默认为
默认
.
访问函数:
| ResizePolicy | resizePolicy () const |
| virtual void | setResizePolicy (ResizePolicy) |
另请参阅 ResizePolicy .
This property holds the mode for the vertical scroll bar.
默认模式为 Q3ScrollView::Auto .
访问函数:
| ScrollBarMode | vScrollBarMode () const |
| virtual void | setVScrollBarMode (ScrollBarMode) |
另请参阅 hScrollBarMode .
This property holds the vertical amount of the content that is visible.
访问函数:
| int | visibleHeight () const |
This property holds the horizontal amount of the content that is visible.
访问函数:
| int | visibleWidth () const |
构造 Q3ScrollView called name 采用父级 parent and widget flags f .
Widget 标志
WStaticContents
,
WNoAutoErase
and
WPaintClever
被传播给
viewport
() widget. The other widget flags are propagated to the parent constructor as usual.
销毁 Q3ScrollView . Any children added with addChild () will be deleted.
[虚拟]
void
Q3ScrollView::
addChild
(
QWidget
*
child
,
int
x
= 0,
int
y
= 0)
Inserts the widget, child , into the scrolled area positioned at ( x , y ). The position defaults to (0, 0). If the child is already in the view, it is just moved.
You may want to call enableClipper (true) if you add a large number of widgets.
返回下边距。
另请参阅 setMargins ().
[slot]
void
Q3ScrollView::
center
(
int
x
,
int
y
)
Scrolls the content so that the point ( x , y ) is in the center of visible area.
[slot]
void
Q3ScrollView::
center
(
int
x
,
int
y
,
float
xmargin
,
float
ymargin
)
这是重载函数。
Scrolls the content so that the point ( x , y ) is visible with the xmargin and ymargin margins (as fractions of visible the area).
例如:
Returns the X position of the given child widget. Use this rather than QWidget::x () for widgets added to the view.
This function returns 0 if child has not been added to the view.
Returns the Y position of the given child widget. Use this rather than QWidget::y () for widgets added to the view.
This function returns 0 if child has not been added to the view.
Returns the clipper widget. Contents in the scrollview are ultimately clipped to be inside the clipper widget.
You should not need to use this function.
另请参阅 visibleWidth () 和 visibleHeight ().
[virtual protected]
void
Q3ScrollView::
contentsContextMenuEvent
(
QContextMenuEvent
*
e
)
This event handler is called whenever the Q3ScrollView 接收 contextMenuEvent () 在 e : the mouse position is translated to be a point on the contents.
[virtual protected]
void
Q3ScrollView::
contentsDragEnterEvent
(
QDragEnterEvent
*
event
)
This event handler is called whenever the Q3ScrollView 接收 dragEnterEvent (): the drag position is translated to be a point on the contents.
The default implementation does nothing. The event 参数被忽略。
[virtual protected]
void
Q3ScrollView::
contentsDragLeaveEvent
(
QDragLeaveEvent
*
event
)
This event handler is called whenever the Q3ScrollView 接收 dragLeaveEvent (): the drag position is translated to be a point on the contents.
The default implementation does nothing. The event 参数被忽略。
[virtual protected]
void
Q3ScrollView::
contentsDragMoveEvent
(
QDragMoveEvent
*
event
)
This event handler is called whenever the Q3ScrollView 接收 dragMoveEvent (): the drag position is translated to be a point on the contents.
The default implementation does nothing. The event 参数被忽略。
[virtual protected]
void
Q3ScrollView::
contentsDropEvent
(
QDropEvent
*
event
)
This event handler is called whenever the Q3ScrollView 接收 dropEvent (): the drop position is translated to be a point on the contents.
The default implementation does nothing. The event 参数被忽略。
[virtual protected]
void
Q3ScrollView::
contentsMouseDoubleClickEvent
(
QMouseEvent
*
e
)
This event handler is called whenever the Q3ScrollView 接收 mouseDoubleClickEvent (): the click position in e is translated to be a point on the contents.
The default implementation generates a normal mouse press event.
[virtual protected]
void
Q3ScrollView::
contentsMouseMoveEvent
(
QMouseEvent
*
e
)
This event handler is called whenever the Q3ScrollView 接收 mouseMoveEvent (): the mouse position in e is translated to be a point on the contents.
[virtual protected]
void
Q3ScrollView::
contentsMousePressEvent
(
QMouseEvent
*
e
)
This event handler is called whenever the Q3ScrollView 接收 mousePressEvent (): the press position in e is translated to be a point on the contents.
[virtual protected]
void
Q3ScrollView::
contentsMouseReleaseEvent
(
QMouseEvent
*
e
)
This event handler is called whenever the Q3ScrollView 接收 mouseReleaseEvent (): the release position in e is translated to be a point on the contents.
[signal]
void
Q3ScrollView::
contentsMoving
(
int
x
,
int
y
)
This signal is emitted just before the contents are moved to position ( x , y ).
另请参阅 contentsX () 和 contentsY ().
Translates a point ( x , y ) in the contents to a point ( vx , vy ) on the viewport () 小部件。
这是重载函数。
Returns the point p translated to a point on the viewport () 小部件。
[virtual protected]
void
Q3ScrollView::
contentsWheelEvent
(
QWheelEvent
*
e
)
This event handler is called whenever the Q3ScrollView 接收 wheelEvent () 在 e : the mouse position is translated to be a point on the contents.
[virtual protected]
void
Q3ScrollView::
contextMenuEvent
(
QContextMenuEvent
*
e
)
重实现自 QWidget::contextMenuEvent ().
返回 2 滚动条之间的角落 Widget。
默认情况下,不存在角落 Widget。
另请参阅 setCornerWidget ().
[virtual protected]
void
Q3ScrollView::
drawContents
(
QPainter
*
p
,
int
clipx
,
int
clipy
,
int
clipw
,
int
cliph
)
Reimplement this function if you are viewing a drawing area rather than a widget.
The function should draw the rectangle ( clipx , clipy , clipw , cliph ) of the contents using painter p . The clip rectangle is in the scrollview's coordinates.
例如:
{
// Fill a 40000 by 50000 rectangle at (100000,150000)
// Calculate the coordinates...
int x1 = 100000, y1 = 150000;
int x2 = x1+40000-1, y2 = y1+50000-1;
// Clip the coordinates so X/Windows will not have problems...
if (x1 < clipx) x1=clipx;
if (y1 < clipy) y1=clipy;
if (x2 > clipx+clipw-1) x2=clipx+clipw-1;
if (y2 > clipy+cliph-1) y2=clipy+cliph-1;
// Paint using the small coordinates...
if (x2 >= x1 && y2 >= y1)
p->fillRect(x1, y1, x2-x1+1, y2-y1+1, red);
}
The clip rectangle and translation of the painter p is already set appropriately.
[virtual protected]
void
Q3ScrollView::
drawContentsOffset
(
QPainter
*
p
,
int
offsetx
,
int
offsety
,
int
clipx
,
int
clipy
,
int
clipw
,
int
cliph
)
For backward-compatibility only. It is easier to use drawContents ( QPainter *,int,int,int,int).
The default implementation translates the painter appropriately and calls drawContents ( QPainter *,int,int,int,int). See drawContents () for an explanation of the parameters p , offsetx , offsety , clipx , clipy , clipw and cliph .
When a large numbers of child widgets are in a scrollview, especially if they are close together, the scrolling performance can suffer greatly. If y is true the scrollview will use an extra widget to group child widgets.
Note that you may only call enableClipper() prior to adding widgets.
[slot]
void
Q3ScrollView::
ensureVisible
(
int
x
,
int
y
)
Scrolls the content so that the point ( x , y ) is visible with at least 50-pixel margins (if possible, otherwise centered).
[slot]
void
Q3ScrollView::
ensureVisible
(
int
x
,
int
y
,
int
xmargin
,
int
ymargin
)
这是重载函数。
Scrolls the content so that the point ( x , y ) is visible with at least the xmargin and ymargin margins (if possible, otherwise centered).
[virtual protected]
bool
Q3ScrollView::
eventFilter
(
QObject
*
obj
,
QEvent
*
e
)
重实现自 QObject::eventFilter ().
This event filter ensures the scroll bars are updated when a single contents widget is resized, shown, hidden or destroyed; it passes mouse events to the Q3ScrollView . The event is in e and the object is in obj .
[virtual protected]
bool
Q3ScrollView::
focusNextPrevChild
(
bool
next
)
重实现自 QWidget::focusNextPrevChild ().
[virtual protected]
void
Q3ScrollView::
frameChanged
()
重实现自 Q3Frame::frameChanged ().
返回 true 若 Q3ScrollView uses a static background; otherwise returns false.
另请参阅 setStaticBackground ().
Returns the component horizontal scroll bar. It is made available to allow accelerators, autoscrolling, etc.
It should not be used for other purposes.
This function never returns 0.
[signal]
void
Q3ScrollView::
horizontalSliderPressed
()
This signal is emitted whenever the user presses the horizontal slider.
[signal]
void
Q3ScrollView::
horizontalSliderReleased
()
This signal is emitted whenever the user releases the horizontal slider.
Returns true if horizontal slider is pressed by user; otherwise returns false.
Returns true if vertical slider is pressed by user; otherwise returns false.
返回左边距。
另请参阅 setMargins ().
[虚拟]
QSize
Q3ScrollView::
minimumSizeHint
() const
重实现自 QWidget::minimumSizeHint ().
[virtual protected]
void
Q3ScrollView::
mouseDoubleClickEvent
(
QMouseEvent
*
e
)
重实现自 QWidget::mouseDoubleClickEvent ().
[virtual protected]
void
Q3ScrollView::
mouseMoveEvent
(
QMouseEvent
*
e
)
重实现自 QWidget::mouseMoveEvent ().
[virtual protected]
void
Q3ScrollView::
mousePressEvent
(
QMouseEvent
*
e
)
重实现自 QWidget::mousePressEvent ().
[virtual protected]
void
Q3ScrollView::
mouseReleaseEvent
(
QMouseEvent
*
e
)
重实现自 QWidget::mouseReleaseEvent ().
[虚拟]
void
Q3ScrollView::
moveChild
(
QWidget
*
child
,
int
x
,
int
y
)
Repositions the child widget to ( x , y ). This function is the same as addChild ().
移除 child widget from the scrolled area. Note that this happens automatically if the child 被删除。
调用 repaint () on a rectangle defined by x , y , w , h , translated appropriately. If the rectangle is not visible, nothing is repainted. If erase is true the background is cleared using the background color.
另请参阅 updateContents ().
这是重载函数。
Repaints the contents of rectangle r 。若 erase is true the background is cleared using the background color.
这是重载函数。
Repaints the contents. If erase is true the background is cleared using the background color.
[virtual slot]
void
Q3ScrollView::
resizeContents
(
int
w
,
int
h
)
Sets the size of the contents area to w pixels wide and h pixels high and updates the viewport accordingly.
[virtual protected]
void
Q3ScrollView::
resizeEvent
(
QResizeEvent
*
event
)
重实现自 QWidget::resizeEvent ().
返回右边距。
另请参阅 setMargins ().
[slot]
void
Q3ScrollView::
scrollBy
(
int
dx
,
int
dy
)
Scrolls the content by dx to the left and dy upwards.
[virtual slot]
void
Q3ScrollView::
setContentsPos
(
int
x
,
int
y
)
Scrolls the content so that the point ( x , y ) is in the top-left corner.
[虚拟]
void
Q3ScrollView::
setCornerWidget
(
QWidget
*
corner
)
Sets the widget in the corner between the two scroll bars.
您可能还想将至少一滚动条模式设为
AlwaysOn
.
传递 0 不展示角落 Widget。
Any previous corner widget is hidden.
可以调用 SetCornerWidget() 在不同时间采用相同 Widget。
All widgets set here will be deleted by the Q3ScrollView when it is destroyed unless you separately reparent the widget after setting some other corner widget (or 0).
任何 newly 设置的 Widget 不应拥有当前父级。
默认情况下,不存在角落 Widget。
另请参阅 cornerWidget (), setVScrollBarMode (),和 setHScrollBarMode ().
[virtual protected]
void
Q3ScrollView::
setHBarGeometry
(
QScrollBar
&
hbar
,
int
x
,
int
y
,
int
w
,
int
h
)
Called when the horizontal scroll bar geometry changes. This is provided as a protected function so that subclasses can do interesting things such as providing extra buttons in some of the space normally used by the scroll bars.
The default implementation simply gives all the space to hbar . The new geometry is given by x , y , w and h .
另请参阅 setVBarGeometry ().
[虚拟]
void
Q3ScrollView::
setMargins
(
int
left
,
int
top
,
int
right
,
int
bottom
)
将卷动区域周围边距设为 left , top , right and bottom . This is useful for applications such as spreadsheets with "locked" rows and columns. The marginal space is inside the frameRect () and is left blank; reimplement drawFrame () or put widgets in the unused area.
默认情况下,所有边距为 0。
另请参阅 frameChanged ().
Sets the scrollview to have a static background if y is true, or a scrolling background if y is false. By default, the background is scrolling.
Be aware that this mode is quite slow, as a full repaint of the visible area has to be triggered on every contents move.
另请参阅 hasStaticBackground ().
[virtual protected]
void
Q3ScrollView::
setVBarGeometry
(
QScrollBar
&
vbar
,
int
x
,
int
y
,
int
w
,
int
h
)
Called when the vertical scroll bar geometry changes. This is provided as a protected function so that subclasses can do interesting things such as providing extra buttons in some of the space normally used by the scroll bars.
The default implementation simply gives all the space to vbar . The new geometry is given by x , y , w and h .
另请参阅 setHBarGeometry ().
[虚拟]
void
Q3ScrollView::
setVisible
(
bool
visible
)
重实现自 QWidget::setVisible ().
[虚拟]
QSize
Q3ScrollView::
sizeHint
() const
重实现自 QWidget::sizeHint ().
Returns the top margin.
另请参阅 setMargins ().
调用 update () on a rectangle defined by x , y , w , h , translated appropriately. If the rectangle is not visible, nothing is repainted.
另请参阅 repaintContents ().
这是重载函数。
Updates the contents in rectangle r
这是重载函数。
[slot]
void
Q3ScrollView::
updateScrollBars
()
Updates scroll bars: all possibilities are considered. You should never need to call this in your code.
Returns the component vertical scroll bar. It is made available to allow accelerators, autoscrolling, etc.
It should not be used for other purposes.
This function never returns 0.
[signal]
void
Q3ScrollView::
verticalSliderPressed
()
This signal is emitted whenever the user presses the vertical slider.
[signal]
void
Q3ScrollView::
verticalSliderReleased
()
This signal is emitted whenever the user releases the vertical slider.
Returns the viewport widget of the scrollview. This is the widget containing the contents widget or which is the drawing area.
[virtual protected]
void
Q3ScrollView::
viewportPaintEvent
(
QPaintEvent
*
pe
)
This is a low-level painting routine that draws the viewport contents. Reimplement this if drawContents () is too high-level (for example, if you don't want to open a QPainter on the viewport). The paint event is passed in pe .
[virtual protected]
void
Q3ScrollView::
viewportResizeEvent
(
QResizeEvent
*
event
)
To provide simple processing of events on the contents, this function receives all resize events sent to the viewport.
The default implementation does nothing. The event 参数被忽略。
另请参阅 QWidget::resizeEvent ().
Returns the viewport size for size ( x , y ).
The viewport size depends on ( x , y ) (the size of the contents), the size of this widget and the modes of the horizontal and vertical scroll bars.
This function permits widgets that can trade vertical and horizontal space for each other to control scroll bar appearance better. For example, a word processor or web browser can control the width of the right margin accurately, whether or not there needs to be a vertical scroll bar.
Translates a point ( vx , vy ) on the viewport () widget to a point ( x , y ) in the contents.
这是重载函数。
Returns the point on the viewport vp translated to a point in the contents.
[virtual protected]
void
Q3ScrollView::
wheelEvent
(
QWheelEvent
*
e
)
重实现自 QWidget::wheelEvent ().