⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qlayoutitem.cpp

📁 奇趣公司比较新的qt/emd版本
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/******************************************************************************** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved.**** This file is part of the QtGui module of the Qt Toolkit.**** This file may be used under the terms of the GNU General Public** License version 2.0 as published by the Free Software Foundation** and appearing in the file LICENSE.GPL included in the packaging of** this file.  Please review the following information to ensure GNU** General Public Licensing requirements will be met:** http://trolltech.com/products/qt/licenses/licensing/opensource/**** If you are unsure which license is appropriate for your use, please** review the following information:** http://trolltech.com/products/qt/licenses/licensing/licensingoverview** or contact the sales department at sales@trolltech.com.**** In addition, as a special exception, Trolltech gives you certain** additional rights. These rights are described in the Trolltech GPL** Exception version 1.0, which can be found at** http://www.trolltech.com/products/qt/gplexception/ and in the file** GPL_EXCEPTION.txt in this package.**** In addition, as a special exception, Trolltech, as the sole copyright** holder for Qt Designer, grants users of the Qt/Eclipse Integration** plug-in the right for the Qt/Eclipse Integration to link to** functionality provided by Qt Designer and its related libraries.**** Trolltech reserves all rights not expressly granted herein.**** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.******************************************************************************/#include "qlayout.h"#include "qapplication.h"#include "qlayoutengine_p.h"#include "qmenubar.h"#include "qtoolbar.h"#include "qevent.h"#include "qstyle.h"#include "qvariant.h"#include "qwidget_p.h"inline static QRect fromLayoutItemRect(QWidgetPrivate *priv, const QRect &rect){    return priv->fromOrToLayoutItemRect(rect, -1);}inline static QSize fromLayoutItemSize(QWidgetPrivate *priv, const QSize &size){    return fromLayoutItemRect(priv, QRect(QPoint(0, 0), size)).size();}inline static QRect toLayoutItemRect(QWidgetPrivate *priv, const QRect &rect){    return priv->fromOrToLayoutItemRect(rect, +1);}inline static QSize toLayoutItemSize(QWidgetPrivate *priv, const QSize &size){    return toLayoutItemRect(priv, QRect(QPoint(0, 0), size)).size();}/*!   Returns a QVariant storing this QSizePolicy.*/QSizePolicy::operator QVariant() const{    return QVariant(QVariant::SizePolicy, this);}/*!    \class QLayoutItem    \brief The QLayoutItem class provides an abstract item that a    QLayout manipulates.    \ingroup appearance    \ingroup geomanagement    This is used by custom layouts.    Pure virtual functions are provided to return information about    the layout, including, sizeHint(), minimumSize(), maximumSize()    and expanding().    The layout's geometry can be set and retrieved with setGeometry()    and geometry(), and its alignment with setAlignment() and    alignment().    isEmpty() returns whether the layout item is empty. If the    concrete item is a QWidget, it can be retrieved using widget().    Similarly for layout() and spacerItem().    Some layouts have width and height interdependencies. These can    be expressed using hasHeightForWidth(), heightForWidth(), and    minimumHeightForWidth(). For more explanation see the \e{Qt    Quarterly} article    \l{http://doc.trolltech.com/qq/qq04-height-for-width.html}{Trading    Height for Width}.    \sa QLayout*//*!    \class QSpacerItem    \ingroup appearance    \ingroup geomanagement    \brief The QSpacerItem class provides blank space in a layout.    Normally, you don't need to use this class directly. Qt's    built-in layout managers provide the following functions for    manipulating empty space in layouts:    \table    \header \o Class            \o Functions    \row    \o QHBoxLayout            \o \l{QBoxLayout::addSpacing()}{addSpacing()},               \l{QBoxLayout::addStretch()}{addStretch()},               \l{QBoxLayout::insertSpacing()}{insertSpacing()},               \l{QBoxLayout::insertStretch()}{insertStretch()}    \row    \o QGridLayout            \o \l{QGridLayout::setRowMinimumHeight()}{setRowMinimumHeight()},               \l{QGridLayout::setRowStretch()}{setRowStretch()},               \l{QGridLayout::setColumnMinimumWidth()}{setColumnMinimumWidth()},               \l{QGridLayout::setColumnStretch()}{setColumnStretch()}    \endtable    \sa QLayout, QWidgetItem, QLayoutItem::spacerItem()*//*!    \class QWidgetItem    \ingroup appearance    \ingroup geomanagement    \brief The QWidgetItem class is a layout item that represents a widget.    Normally, you don't need to use this class directly. Qt's    built-in layout managers provide the following functions for    manipulating widgets in layouts:    \table    \header \o Class            \o Functions    \row    \o QBoxLayout            \o \l{QBoxLayout::addWidget()}{addWidget()},               \l{QBoxLayout::insertWidget()}{insertWidget()},               \l{QBoxLayout::setStretchFactor()}{setStretchFactor()}    \row    \o QGridLayout            \o \l{QGridLayout::addWidget()}{addWidget()}    \row    \o QStackedLayout            \o \l{QStackedLayout::addWidget()}{addWidget()},               \l{QStackedLayout::insertWidget()}{insertWidget()},               \l{QStackedLayout::currentWidget()}{currentWidget()},               \l{QStackedLayout::setCurrentWidget()}{setCurrentWidget()},               \l{QStackedLayout::widget()}{widget()}    \endtable    \sa QLayout, QSpacerItem, QLayoutItem::widget()*//*!    \fn QLayoutItem::QLayoutItem(Qt::Alignment alignment)    Constructs a layout item with an \a alignment.    Not all subclasses support alignment.*//*!    \fn Qt::Alignment QLayoutItem::alignment() const    Returns the alignment of this item.*//*!    Sets the alignment of this item to \a alignment.    \bold{Note:} Item alignment is only supported by QLayoutItem subclasses    where it would have a visual effect. Except for QSpacerItem, which provides    blank space for layouts, all public Qt classes that inherit QLayoutItem    support item alignment.*/void QLayoutItem::setAlignment(Qt::Alignment alignment){    align = alignment;}/*!    \fn QSize QLayoutItem::maximumSize() const    Implemented in subclasses to return the maximum size of this item.*//*!    \fn QSize QLayoutItem::minimumSize() const    Implemented in subclasses to return the minimum size of this item.*//*!    \fn QSize QLayoutItem::sizeHint() const    Implemented in subclasses to return the preferred size of this item.*//*!    \fn Qt::Orientations QLayoutItem::expandingDirections() const    Returns whether this layout item can make use of more space than    sizeHint(). A value of Qt::Vertical or Qt::Horizontal means that    it wants to grow in only one dimension, whereas Qt::Vertical |    Qt::Horizontal means that it wants to grow in both dimensions.*//*!    \fn void QLayoutItem::setGeometry(const QRect &r)    Implemented in subclasses to set this item's geometry to \a r.    \sa geometry()*//*!    \fn QRect QLayoutItem::geometry() const    Returns the rectangle covered by this layout item.    \sa setGeometry()*//*!    \fn virtual bool QLayoutItem::isEmpty() const    Implemented in subclasses to return whether this item is empty,    i.e. whether it contains any widgets.*//*!    \fn QSpacerItem::QSpacerItem(int w, int h, QSizePolicy::Policy hPolicy, QSizePolicy::Policy vPolicy)    Constructs a spacer item with preferred width \a w, preferred    height \a h, horizontal size policy \a hPolicy and vertical size    policy \a vPolicy.    The default values provide a gap that is able to stretch if    nothing else wants the space.*//*!    Changes this spacer item to have preferred width \a w, preferred    height \a h, horizontal size policy \a hPolicy and vertical size    policy \a vPolicy.    The default values provide a gap that is able to stretch if    nothing else wants the space.    Note that if changeSize() is called after the spacer item has been added    to a layout, it is necessary to invalidate the layout in order for the    spacer item's new size to take effect.    \sa QSpacerItem::invalidate()*/void QSpacerItem::changeSize(int w, int h, QSizePolicy::Policy hPolicy,                             QSizePolicy::Policy vPolicy){    width = w;    height = h;    sizeP = QSizePolicy(hPolicy, vPolicy);}/*!    \fn QWidgetItem::QWidgetItem(QWidget *widget)    Creates an item containing the given \a widget.*//*!    Destroys the QLayoutItem.*/QLayoutItem::~QLayoutItem(){}/*!    Invalidates any cached information in this layout item.*/void QLayoutItem::invalidate(){}/*!    If this item is a QLayout, it is returned as a QLayout; otherwise    0 is returned. This function provides type-safe casting.*/QLayout * QLayoutItem::layout(){    return 0;}/*!    If this item is a QSpacerItem, it is returned as a QSpacerItem;    otherwise 0 is returned. This function provides type-safe casting.*/QSpacerItem * QLayoutItem::spacerItem(){    return 0;}/*!    \reimp*/QLayout * QLayout::layout(){    return this;}/*!    Returns a pointer to this object.*/QSpacerItem * QSpacerItem::spacerItem(){    return this;}/*!    If this item is a QWidget, it is returned as a QWidget; otherwise    0 is returned. This function provides type-safe casting.*/QWidget * QLayoutItem::widget(){

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -