返回介绍

QSplitter Class

发布于 2019-10-04 15:02:50 字数 9495 浏览 984 评论 0 收藏 0

The QSplitter class implements a splitter widget. More...

#include <qsplitter.h>

Inherits QFrame.

List of all member functions.

Public Members

  • enum ResizeMode { Stretch, KeepSize, FollowSizeHint }
  • QSplitter ( QWidget*parent = 0, constchar*name = 0 )
  • QSplitter ( Orientationo, QWidget*parent = 0, constchar*name = 0 )
  • ~QSplitter ()
  • virtual void setOrientation ( Orientation )
  • Orientation orientation () const
  • virtual void setResizeMode ( QWidget*w, ResizeModemode )
  • virtual void setOpaqueResize ( boolon = TRUE )
  • bool opaqueResize () const
  • void moveToFirst ( QWidget*w )
  • void moveToLast ( QWidget*w )
  • void refresh ()
  • QValueList<int> sizes () const
  • void setSizes ( QValueList<int>list )

Properties

  • Orientation orientation- the orientation of the splitter

Protected Members

  • virtual void childEvent ( QChildEvent*c )
  • int idAfter ( QWidget*w ) const
  • void moveSplitter ( QCOORDp, intid )
  • virtual void drawSplitter ( QPainter*p, QCOORDx, QCOORDy, QCOORDw, QCOORDh ) (obsolete)
  • int adjustPos ( intp, intid )
  • virtual void setRubberband ( intp )
  • void getRange ( intid, int*min, int*max )

Detailed Description

The QSplitter class implements a splitter widget.

A splitter lets the user control the size of child widgets by dragging the boundary between the children. Any number of widgets may be controlled.

To show a QListBox, a QListView and a QTextEdit side by side:

    QSplitter *split = new QSplitter( parent );
    QListBox *lb = new QListBox( split );
    QListView *lv = new QListView( split );
    QTextEdit *ed = new QTextEdit( split );
  

In QSplitter the boundary can be either horizontal or vertical. The default is horizontal (the children are side by side) but you can use setOrientation( QSplitter::Vertical ) to set it to vertical.

By default, all widgets can be as large or as small as the user wishes, down to minimumSizeHint(). You can also use setMinimumSize() and setMaximumSize() on the children. Use setResizeMode() to specify that a widget should keep its size when the splitter is resized.

Although QSplitter normally resizes the children only at the end of a resize operation, if you call setOpaqueResize( TRUE ) the widgets are resized as often as possible.

The initial distribution of size between the widgets is determined by the initial size of each widget. You can also use setSizes() to set the sizes of all the widgets. The function sizes() returns the sizes set by the user.

If you hide() a child its space will be distributed among the other children. It will be reinstated when you show() it again. It is also possible to reorder the widgets within the splitter using moveToFirst() and moveToLast().

See also QTabBar and Organizers.


Member Type Documentation

QSplitter::ResizeMode

This enum type describes how QSplitter will resize each of its child widgets. The currently defined values are:

  • QSplitter::Stretch - the widget will be resized when the splitter itself is resized.
  • QSplitter::KeepSize - QSplitter will try to keep this widget's size unchanged.
  • QSplitter::FollowSizeHint - QSplitter will resize the widget when the widget's size hint changes.

Member Function Documentation

QSplitter::QSplitter ( QWidget*parent = 0, constchar*name = 0 )

Constructs a horizontal splitter with the parent and name arguments being passed on to the QFrame constructor.

QSplitter::QSplitter ( Orientationo, QWidget*parent = 0, constchar*name = 0 )

Constructs a splitter with orientation o with the parent and name arguments being passed on to the QFrame constructor.

QSplitter::~QSplitter ()

Destroys the splitter and any children.

int QSplitter::adjustPos ( intp, intid ) [protected]

Returns the closest legal position to p of the splitter with id id.

See also idAfter().

void QSplitter::childEvent ( QChildEvent*c ) [virtual protected]

Tells the splitter that a child widget has been inserted or removed. The event is passed in c.

Reimplemented from QObject.

void QSplitter::drawSplitter ( QPainter*p, QCOORDx, QCOORDy, QCOORDw, QCOORDh ) [virtual protected]

This function is obsolete. It is provided to keep old source working. We strongly advise against using it in new code.

Draws the splitter handle in the rectangle described by x, y, w, h using painter p.

See also QStyle::drawPrimitive().

void QSplitter::getRange ( intid, int*min, int*max ) [protected]

Returns the valid range of the splitter with id id in *min and *max.

See also idAfter().

int QSplitter::idAfter ( QWidget*w ) const [protected]

Returns the id of the splitter to the right of or below the widget w, or 0 if there is no such splitter (i.e. it is either not in this QSplitter or it is at the end).

void QSplitter::moveSplitter ( QCOORDp, intid ) [protected]

Moves the left/top edge of the splitter handle with id id as close as possible to position p, which is the distance from the left (or top) edge of the widget.

For Arabic and Hebrew the layout is reversed, and using this function to set the position of the splitter might lead to unexpected results, since in Arabic and Hebrew the position of splitter one is to the left of the position of splitter zero.

See also idAfter().

void QSplitter::moveToFirst ( QWidget*w )

Moves widget w to the leftmost/top position.

Example: splitter/splitter.cpp.

void QSplitter::moveToLast ( QWidget*w )

Moves widget w to the rightmost/bottom position.

bool QSplitter::opaqueResize () const

Returns TRUE if opaque resize is on; otherwise returns FALSE.

See also setOpaqueResize().

Orientation QSplitter::orientation () const

Returns the orientation of the splitter. See the "orientation" property for details.

void QSplitter::refresh ()

Updates the splitter's state. You should not need to call this function.

void QSplitter::setOpaqueResize ( boolon = TRUE ) [virtual]

If on is TRUE then opaque resizing is turned on; otherwise opaque resizing is turned off. Opaque resizing is initially turned off.

See also opaqueResize().

Examples: mainlyQt/editor.cpp and splitter/splitter.cpp.

void QSplitter::setOrientation ( Orientation ) [virtual]

Sets the orientation of the splitter. See the "orientation" property for details.

void QSplitter::setResizeMode ( QWidget*w, ResizeModemode ) [virtual]

Sets resize mode of w to mode.

See also ResizeMode.

Examples: fileiconview/mainwindow.cpp, listviews/listviews.cpp, network/ftpclient/ftpmainwindow.cpp and splitter/splitter.cpp.

void QSplitter::setRubberband ( intp ) [virtual protected]

Shows a rubber band at position p. If p is negative, the rubber band is removed.

void QSplitter::setSizes ( QValueList<int>list )

Sets the size parameters to the values given in list. If the splitter is horizontal, the values set the sizes from left to right. If it is vertical, the sizes are applied from top to bottom. Extra values in list are ignored.

If list contains too few values, the result is undefined but the program will still be well-behaved.

See also sizes().

QValueList<int> QSplitter::sizes () const

Returns a list of the size parameters of all the widgets in this splitter.

Giving the values to another splitter's setSizes() function will produce a splitter with the same layout as this one.

Note that if you want to iterate over the list, you should iterate over a copy, e.g.

    QValueList<int> list = mySplitter.sizes();
    QValueList<int>::Iterator it = list.begin();
    while( it != list.end() ) {
        myProcessing( *it );
        ++it;
    }
    

See also setSizes().


Property Documentation

Orientation orientation

This property holds the orientation of the splitter.

By default the orientation is horizontal (the widgets are side by side). The possible orientations are Qt:Vertical and Qt::Horizontal (the default).

Set this property's value with setOrientation() and get this property's value with orientation().

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文