Eneboo - Documentación para desarrolladores
|
The QLayout class is the base class of geometry managers. Más...
#include <qlayout.h>
The QLayout class is the base class of geometry managers.
This is an abstract base class inherited by the concrete classes, QBoxLayout and QGridLayout.
For users of QLayout subclasses or of QMainWindow there is seldom any need to use the basic functions provided by QLayout, such as setResizeMode() or setMenuBar(). See the layout overview page for more information.
To make your own layout manager, subclass QGLayoutIterator and implement the functions addItem(), sizeHint(), setGeometry(), and iterator(). You should also implement minimumSize() to ensure your layout isn't resized to zero size if there is too little space. To support children whose heights depend on their widths, implement hasHeightForWidth() and heightForWidth(). See the custom layout page for an in-depth description.
Geometry management stops when the layout manager is deleted.
enum QLayout::ResizeMode |
The possible values are:
Auto If the main widget is a top-level widget with no height-for-width (hasHeightForWidth()), this is the same as Minimium
; otherwise, this is the same as FreeResize
. Fixed The main widget's size is set to sizeHint(); it cannot be resized at all. Minimum The main widget's minimum size is set to minimumSize(); it cannot be smaller. FreeResize The widget is not constrained.
enum QLayout::ResizeMode |
Constructs a new top-level QLayout called name, with main widget parent. parent may not be 0.
The margin is the number of pixels between the edge of the widget and the managed children. The spacing sets the value of spacing(), which gives the spacing between the managed widgets. If spacing is -1 (the default), spacing is set to the value of margin.
There can be only one top-level layout for a widget. It is returned by QWidget::layout()
QLayout::QLayout | ( | int | spacing = -1 , |
const char * | name = 0 |
||
) |
QLayout::~QLayout | ( | ) |
QLayout::QLayout | ( | int | spacing = -1 , |
const char * | name = 0 |
||
) |
QLayout::~QLayout | ( | ) |
bool QLayout::activate | ( | ) |
Redoes the layout for mainWidget(). You should generally not need to call this because it is automatically called at the most appropriate times.
However, if you set up a QLayout for a visible widget without resizing that widget, you will need to call this function in order to lay it out.
bool QLayout::activate | ( | ) |
void QLayout::add | ( | QWidget * | w | ) | [inline] |
Adds widget w to this layout in a manner specific to the layout. This function uses addItem().
void QLayout::add | ( | QWidget * | w | ) | [inline] |
void QLayout::addChildLayout | ( | QLayout * | l | ) | [protected] |
This function is called from addLayout() functions in subclasses to add layout l as a sub-layout.
void QLayout::addChildLayout | ( | QLayout * | l | ) | [protected] |
void QLayout::addItem | ( | QLayoutItem * | item | ) | [pure virtual] |
Implemented in subclasses to add an item. How it is added is specific to each subclass.
The ownership of item is transferred to the layout, and it's the layout's responsibility to delete it.
Implementado en QDockAreaLayout, QGridLayout, QBoxLayout, QGridLayout, QBoxLayout, QDockAreaLayout, QMainWindowLayout y QwtDynGridLayout.
virtual void QLayout::addItem | ( | QLayoutItem * | ) | [pure virtual] |
Implementado en QDockAreaLayout, QGridLayout, QBoxLayout, QGridLayout, QBoxLayout, QDockAreaLayout, QMainWindowLayout y QwtDynGridLayout.
Returns the rectangle that should be covered when the geometry of this layout is set to r, provided that this layout supports setAlignment().
The result is derived from sizeHint() and expanding(). It is never larger than r.
bool QLayout::autoAdd | ( | ) | const [inline] |
Returns TRUE if this layout automatically grabs all new mainWidget()'s new children and adds them as defined by addItem(); otherwise returns FALSE. This has effect only for top-level layouts, i.e. layouts that are direct children of their mainWidget().
autoAdd() is disabled by default.
Note that a top-level layout is not necessarily associated with the top-level widget.
bool QLayout::autoAdd | ( | ) | const [inline] |
void QLayout::childEvent | ( | QChildEvent * | e | ) | [protected, virtual] |
Reimplementado de QObject.
void QLayout::childEvent | ( | QChildEvent * | ) | [protected, virtual] |
This event handler can be reimplemented in a subclass to receive child events.
Child events are sent to objects when children are inserted or removed.
Note that events with QEvent::type() QEvent::ChildInserted
are posted (with {QApplication::postEvent()}) to make sure that the child's construction is completed before this function is called.
If a child is removed immediately after it is inserted, the ChildInserted
event may be suppressed, but the ChildRemoved
event will always be sent. In such cases it is possible that there will be a ChildRemoved
event without a corresponding ChildInserted
event.
If you change state based on ChildInserted
events, call QWidget::constPolish(), or do
in functions that depend on the state. One notable example is QWidget::sizeHint().
Reimplementado de QObject.
int QLayout::defaultBorder | ( | ) | const [inline] |
int QLayout::defaultBorder | ( | ) | const [inline] |
void QLayout::deleteAllItems | ( | ) | [protected] |
void QLayout::deleteAllItems | ( | ) | [protected] |
Removes and deletes all items in this layout.
Performs child widget layout when the parent widget is resized. Also handles removal of widgets and child layouts. e is the event the occurred on object o.
Reimplementado de QObject.
Filters events if this object has been installed as an event filter for the watched object.
In your reimplementation of this function, if you want to filter the event e, out, i.e. stop it being handled further, return TRUE; otherwise return FALSE.
Example:
class MyMainWindow : public QMainWindow { public: MyMainWindow( QWidget *parent = 0, const char *name = 0 ); protected: bool eventFilter( QObject *obj, QEvent *ev ); private: QTextEdit *textEdit; }; MyMainWindow::MyMainWindow( QWidget *parent, const char *name ) : QMainWindow( parent, name ) { textEdit = new QTextEdit( this ); setCentralWidget( textEdit ); textEdit->installEventFilter( this ); } bool MyMainWindow::eventFilter( QObject *obj, QEvent *ev ) { if ( obj == textEdit ) { if ( e->type() == QEvent::KeyPress ) { QKeyEvent *k = (QKeyEvent*)ev; qDebug( "Ate key press %d", k->key() ); return TRUE; } else { return FALSE; } } else { // pass the event on to the parent class return QMainWindow::eventFilter( obj, ev ); } }
Notice in the example above that unhandled events are passed to the base class's eventFilter() function, since the base class might have reimplemented eventFilter() for its own internal purposes.
Reimplementado de QObject.
QSizePolicy::ExpandData QLayout::expanding | ( | ) | const [virtual] |
Implemented in subclasses to return the direction(s) this item "wants" to expand in (if any).
Implementa QLayoutItem.
Reimplementado en QDockAreaLayout, QGridLayout, QBoxLayout, QGridLayout, QBoxLayout, QDockAreaLayout, QDockWindowGridLayout, QMainWindowLayout y QwtDynGridLayout.
QSizePolicy::ExpandData QLayout::expanding | ( | ) | const [virtual] |
Returns whether this layout can make use of more space than sizeHint(). A value of Vertical
or Horizontal
means that it wants to grow in only one dimension, whereas BothDirections
means that it wants to grow in both dimensions.
The default implementation returns BothDirections
.
Implementa QLayoutItem.
Reimplementado en QDockAreaLayout, QGridLayout, QBoxLayout, QGridLayout, QBoxLayout, QDockAreaLayout, QDockWindowGridLayout, QMainWindowLayout y QwtDynGridLayout.
void QLayout::freeze | ( | ) | [inline] |
void QLayout::freeze | ( | ) | [inline] |
QRect QLayout::geometry | ( | ) | const [virtual] |
Implementa QLayoutItem.
QRect QLayout::geometry | ( | ) | const [virtual] |
Returns the rectangle covered by this layout item.
Implementa QLayoutItem.
void QLayout::invalidate | ( | ) | [virtual] |
Invalidates cached information. Reimplementations must call this.
Reimplementado de QLayoutItem.
Reimplementado en QDockAreaLayout, QGridLayout, QBoxLayout, QGridLayout, QBoxLayout, QDockAreaLayout, QMainWindowLayout y QwtDynGridLayout.
void QLayout::invalidate | ( | ) | [virtual] |
Invalidates any cached information in this layout item.
Reimplementado de QLayoutItem.
Reimplementado en QDockAreaLayout, QGridLayout, QBoxLayout, QGridLayout, QBoxLayout, QDockAreaLayout, QMainWindowLayout y QwtDynGridLayout.
bool QLayout::isEmpty | ( | void | ) | const [virtual] |
Implemented in subclasses to return whether this item is empty, i.e. whether it contains any widgets.
Implementa QLayoutItem.
Reimplementado en QwtDynGridLayout.
bool QLayout::isEmpty | ( | void | ) | const [virtual] |
Returns TRUE if this layout is empty. The default implementation returns FALSE.
Implementa QLayoutItem.
Reimplementado en QwtDynGridLayout.
bool QLayout::isEnabled | ( | ) | const |
Returns TRUE if the layout is enabled; otherwise returns FALSE.
bool QLayout::isEnabled | ( | ) | const |
bool QLayout::isTopLevel | ( | ) | const [inline] |
Returns TRUE if this layout is a top-level layout, i.e. not a child of another layout; otherwise returns FALSE.
bool QLayout::isTopLevel | ( | ) | const [inline] |
QLayoutIterator QLayout::iterator | ( | ) | [pure virtual] |
Returns an iterator over this item's QLayoutItem children. The default implementation returns an empty iterator.
Reimplement this function in subclasses that can have children.
Reimplementado de QLayoutItem.
Implementado en QDockAreaLayout, QGridLayout, QBoxLayout, QGridLayout, QBoxLayout, QDockAreaLayout, QMainWindowLayout y QwtDynGridLayout.
QLayoutIterator QLayout::iterator | ( | ) | [pure virtual] |
Implemented in subclasses to return an iterator that iterates over this layout's children.
A typical implementation will be:
QLayoutIterator MyLayout::iterator() { QGLayoutIterator *i = new MyLayoutIterator( internal_data ); return QLayoutIterator( i ); }
where MyLayoutIterator is a subclass of QGLayoutIterator.
Reimplementado de QLayoutItem.
Implementado en QDockAreaLayout, QGridLayout, QBoxLayout, QGridLayout, QBoxLayout, QDockAreaLayout, QMainWindowLayout y QwtDynGridLayout.
QLayout * QLayout::layout | ( | ) | [virtual] |
Reimplementado de QLayoutItem.
QLayout* QLayout::layout | ( | ) | [virtual] |
If this item is a QLayout, it is returned as a QLayout; otherwise 0 is returned. This function provides type-safe casting.
Reimplementado de QLayoutItem.
QWidget * QLayout::mainWidget | ( | ) |
Returns the main widget (parent widget) of this layout, or 0 if this layout is a sub-layout that is not yet inserted.
QWidget* QLayout::mainWidget | ( | ) |
int QLayout::margin | ( | ) | const [inline] |
int QLayout::margin | ( | ) | const [inline] |
QSize QLayout::maximumSize | ( | ) | const [virtual] |
Implemented in subclasses to return the maximum size of this item.
Implementa QLayoutItem.
Reimplementado en QGridLayout, QBoxLayout, QGridLayout y QBoxLayout.
QSize QLayout::maximumSize | ( | ) | const [virtual] |
Returns the maximum size of this layout. This is the largest size that the layout can have while still respecting the specifications. Does not include what's needed by margin() or menuBar().
The default implementation allows unlimited resizing.
Implementa QLayoutItem.
Reimplementado en QGridLayout, QBoxLayout, QGridLayout y QBoxLayout.
QMenuBar * QLayout::menuBar | ( | ) | const [inline] |
Returns the menu bar set for this layout, or 0 if no menu bar is set.
QMenuBar* QLayout::menuBar | ( | ) | const [inline] |
QSize QLayout::minimumSize | ( | ) | const [virtual] |
Implemented in subclasses to return the minimum size of this item.
Implementa QLayoutItem.
Reimplementado en QDockAreaLayout, QGridLayout, QBoxLayout, QGridLayout, QBoxLayout, QDockAreaLayout y QMainWindowLayout.
QSize QLayout::minimumSize | ( | ) | const [virtual] |
Returns the minimum size of this layout. This is the smallest size that the layout can have while still respecting the specifications. Does not include what's needed by margin() or menuBar().
The default implementation allows unlimited resizing.
Implementa QLayoutItem.
Reimplementado en QDockAreaLayout, QGridLayout, QBoxLayout, QGridLayout, QBoxLayout, QDockAreaLayout y QMainWindowLayout.
void QLayout::remove | ( | QWidget * | w | ) |
void QLayout::remove | ( | QWidget * | widget | ) |
Removes the widget widget from the layout. After this call, it is the caller's responsibility to give the widget a reasonable geometry or to put the widget back into a layout.
void QLayout::removeItem | ( | QLayoutItem * | ) |
void QLayout::removeItem | ( | QLayoutItem * | item | ) |
Removes the layout item item from the layout. It is the caller's responsibility to delete the item.
Notice that item can be a layout (since QLayout inherits QLayoutItem).
ResizeMode QLayout::resizeMode | ( | ) | const |
ResizeMode QLayout::resizeMode | ( | ) | const |
virtual void QLayout::setAutoAdd | ( | bool | ) | [virtual] |
void QLayout::setAutoAdd | ( | bool | b | ) | [virtual] |
If b is TRUE, auto-add is enabled; otherwise auto-add is disabled.
void QLayout::setEnabled | ( | bool | enable | ) |
Enables this layout if enable is TRUE, otherwise disables it.
An enabled layout adjusts dynamically to changes; a disabled layout acts as if it did not exist.
By default all layouts are enabled.
void QLayout::setEnabled | ( | bool | ) |
void QLayout::setGeometry | ( | const QRect & | r | ) | [pure virtual] |
This function is reimplemented in subclasses to perform layout.
The default implementation maintains the geometry() information given by rect r. Reimplementors must call this function.
Implementa QLayoutItem.
Implementado en QDockAreaLayout, QGridLayout, QBoxLayout, QGridLayout, QBoxLayout, QDockAreaLayout, QMainWindowLayout y QwtDynGridLayout.
void QLayout::setGeometry | ( | const QRect & | r | ) | [pure virtual] |
Implemented in subclasses to set this item's geometry to r.
Implementa QLayoutItem.
Implementado en QDockAreaLayout, QGridLayout, QBoxLayout, QGridLayout, QBoxLayout, QDockAreaLayout, QMainWindowLayout y QwtDynGridLayout.
virtual void QLayout::setMargin | ( | int | ) | [virtual] |
void QLayout::setMargin | ( | int | margin | ) | [virtual] |
void QLayout::setMenuBar | ( | QMenuBar * | w | ) | [virtual] |
Makes the geometry manager take account of the menu bar w. All child widgets are placed below the bottom edge of the menu bar.
A menu bar does its own geometry management: never do addWidget() on a QMenuBar.
virtual void QLayout::setMenuBar | ( | QMenuBar * | w | ) | [virtual] |
void QLayout::setResizeMode | ( | ResizeMode | mode | ) |
void QLayout::setResizeMode | ( | ResizeMode | ) |
virtual void QLayout::setSpacing | ( | int | ) | [virtual] |
void QLayout::setSpacing | ( | int | spacing | ) | [virtual] |
void QLayout::setSupportsMargin | ( | bool | ) | [protected] |
void QLayout::setSupportsMargin | ( | bool | b | ) | [protected] |
Sets the value returned by supportsMargin(). If b is TRUE, margin() handling is implemented by the subclass. If b is FALSE (the default), QLayout will add margin() around top-level layouts.
If b is TRUE, margin handling needs to be implemented in setGeometry(), maximumSize(), minimumSize(), sizeHint() and heightForWidth().
int QLayout::spacing | ( | ) | const [inline] |
int QLayout::spacing | ( | ) | const [inline] |
bool QLayout::supportsMargin | ( | ) | const [inline] |
bool QLayout::supportsMargin | ( | ) | const [inline] |
Returns TRUE if this layout supports QLayout::margin on non-top-level layouts; otherwise returns FALSE.
QSize QLayout::totalMaximumSize | ( | ) | const |
QSize QLayout::totalMaximumSize | ( | ) | const |
QSize QLayout::totalMinimumSize | ( | ) | const |
QSize QLayout::totalMinimumSize | ( | ) | const |
QSize QLayout::totalSizeHint | ( | ) | const |
QSize QLayout::totalSizeHint | ( | ) | const |
int QLayout::margin [read, write] |
the width of the outside border of the layout
For some layout classes this property has an effect only on top-level layouts; QBoxLayout and QGridLayout support margins for child layouts. The default value is 0.
ResizeMode QLayout::resizeMode [read, write] |
int QLayout::spacing [read, write] |
the spacing between widgets inside the layout
The default value is -1, which signifies that the layout's spacing should not override the widget's spacing.