QSize Class Reference

#include <qsize.h>

List of all members.


Detailed Description

The QSize class defines the size of a two-dimensional object using integer point precision.

A size is specified by a width() and a height(). It can be set in the constructor and changed using the setWidth(), setHeight(), or scale() functions, or using arithmetic operators. A size can also be manipulated directly by retrieving references to the width and height using the rwidth() and rheight() functions. Finally, the width and height can be swapped using the transpose() function.

The isValid() function determines if a size is valid (a valid size has both width and height greater than zero). The isEmpty() function returns true if either of the width and height is less than, or equal to, zero, while the isNull() function returns true only if both the width and the height is zero.

Use the expandedTo() function to retrieve a size which holds the maximum height and width of this size and a given size. Similarly, the boundedTo() function returns a size which holds the minimum height and width of this size and a given size.

QSize objects can be streamed as well as compared.

See also:
QSizeF, QPoint, QRect

Definition at line 33 of file qsize.h.

Public Member Functions

 QSize ()
 QSize (int w, int h)
bool isNull () const
bool isEmpty () const
bool isValid () const
int width () const
int height () const
void setWidth (int w)
void setHeight (int h)
void transpose ()
void scale (int w, int h, Qt::AspectRatioMode mode)
void scale (const QSize &s, Qt::AspectRatioMode mode)
QSize expandedTo (const QSize &) const
QSize boundedTo (const QSize &) const
int & rwidth ()
int & rheight ()
QSizeoperator+= (const QSize &)
QSizeoperator-= (const QSize &)
QSizeoperator *= (qreal c)
QSizeoperator/= (qreal c)

Private Attributes

int wd
int ht

Friends

bool operator== (const QSize &, const QSize &)
bool operator!= (const QSize &, const QSize &)
const QSize operator+ (const QSize &, const QSize &)
const QSize operator- (const QSize &, const QSize &)
const QSize operator * (const QSize &, qreal)
const QSize operator * (qreal, const QSize &)
const QSize operator/ (const QSize &, qreal)

Related Functions

(Note that these are not member functions.)

QDataStreamoperator<< (QDataStream &stream, const QSize &size)
QDataStreamoperator>> (QDataStream &stream, QSize &size)


Constructor & Destructor Documentation

QSize::QSize (  )  [inline]

Constructs a size with an invalid width and height (i.e., isValid() returns false).

See also:
isValid()

Definition at line 89 of file qsize.h.

References ht, and wd.

Referenced by boundedTo(), expandedTo(), and scale().

00090 { wd = ht = -1; }

QSize::QSize ( int  width,
int  height 
) [inline]

Constructs a size with the given width and height.

See also:
setWidth(), setHeight()

Definition at line 92 of file qsize.h.

References ht, and wd.

00093 { wd = w; ht = h; }


Member Function Documentation

bool QSize::isNull (  )  const [inline]

Returns true if both the width and height is 0; otherwise returns false.

See also:
isValid(), isEmpty()

Definition at line 95 of file qsize.h.

References ht, and wd.

Referenced by QPixmapIconEngine::actualSize(), QPixmapIconEngine::bestMatch(), Q3MainWindowLayout::minimumSize(), Q3WidgetStack::minimumSizeHint(), QPixmapIconEngine::pixmap(), Q3WidgetStack::sizeHint(), Q3ComboBoxPopupItem::sizeHint(), and QTabBar::tabSizeHint().

00096 { return wd==0 && ht==0; }

bool QSize::isEmpty (  )  const [inline]

Returns true if either of the width and height is less than or equal to 0; otherwise returns false.

See also:
isNull(), isValid()

Definition at line 98 of file qsize.h.

References ht, and wd.

Referenced by QSvgTinyDocument::adjustWindowBounds(), QMenuBarPrivate::calcActionRects(), QMenuPrivate::calcActionRects(), QItemDelegate::doLayout(), qdesigner_internal::QtColorLinePrivate::isMainPixmapValid(), QSvgIOHandler::read(), qdesigner_internal::QtColorLinePrivate::recreateMainPixmap(), QPixmap::setMask(), QBoxLayoutPrivate::setupGeom(), QWindowsXPStyle::sizeFromContents(), QMotifStyle::sizeFromContents(), and QWindowsStyle::sizeFromContents().

00099 { return wd<1 || ht<1; }

bool QSize::isValid (  )  const [inline]

Returns true if both the width and height is equal to or greater than 0; otherwise returns false.

See also:
isNull(), isEmpty()

Definition at line 101 of file qsize.h.

References ht, and wd.

Referenced by Q3IconView::arrangeItemsInGrid(), QPixmapIconEngine::bestMatch(), QWorkspace::cascade(), QListViewPrivate::doDynamicLayout(), QListViewPrivate::doStaticLayout(), QDockWidgetLayout::getGrid(), QListViewPrivate::indexToListViewItem(), QListViewPrivate::initDynamicLayout(), QListViewPrivate::itemSize(), QMainWindowLayout::minimumSize(), QMoviePrivate::next(), QImageReader::read(), read_jpeg_image(), QComboBoxPrivate::recomputeSizeHint(), MainWindow::renderIntoPixmap(), Q3ScrollView::setCachedSizeHint(), QToolBar::setIconSize(), QMainWindow::setIconSize(), QMainWindowLayout::sizeHint(), Q3ComboBox::sizeHint(), Q3ScrollView::sizeHint(), and QTreeViewPrivate::updateScrollBars().

00102 { return wd>=0 && ht>=0; }

int QSize::width (  )  const [inline]

Returns the width.

See also:
height(), setWidth()

Definition at line 104 of file qsize.h.

References wd.

Referenced by QTextEditPrivate::_q_adjustScrollbars(), QPushButtonPrivate::_q_popupPressed(), QWorkspacePrivate::_q_showOperationMenu(), QCalendarWidgetPrivate::_q_yearClicked(), QLayout::activate(), QPixmapIconEngine::actualSize(), QGridLayoutPrivate::addData(), QView3DWidget::addWidget(), Q3ListView::adjustColumn(), Q3Table::adjustColumn(), QSvgTinyDocument::adjustWindowBounds(), QStyle::alignedRect(), QLayout::alignmentRect(), QDockAreaLayoutInfo::apply(), Q3IconView::arrangeItemsInGrid(), Q3ScrollViewData::autoResizeHint(), QBalloonTip::balloon(), QRenderRule::boxSize(), Dialog::buttonsOrientationChanged(), QMenuBarPrivate::calcActionRects(), QMenuPrivate::calcActionRects(), BorderLayout::calculateSize(), QWorkspace::cascade(), ColorDock::changeSizeHints(), Q3ToolBar::checkForExtension(), QVFb::chooseSize(), Q3ListView::clear(), QLayout::closestAcceptableSize(), QComboBoxPrivate::computeWidthHint(), QAbstractFormBuilder::createDom(), decorationFromDomWidget(), QListViewPrivate::doDynamicLayout(), QItemDelegate::doLayout(), Q3ListBox::doLayout(), FlowLayout::doLayout(), QLayoutPrivate::doResize(), QListViewPrivate::doStaticLayout(), QListViewPrivate::draggedItemsDelta(), QRenderRule::drawBorder(), QWindowsXPStyle::drawControl(), QCommonStyle::drawControl(), qdesigner_internal::QtGradientStopsWidgetPrivate::ensureVisible(), HoverPoints::eventFilter(), expandedSize(), QTabBarPrivate::extraWidth(), QListViewPrivate::flipX(), QBitmap::fromData(), genIcon(), QDockWidgetLayout::getGrid(), QRenderRule::getRadii(), QComboMenuDelegate::getStyleOption(), qdesigner_internal::QtColorLinePrivate::gradientPixmap(), qdesigner_internal::QtColorLinePrivate::hueGradientPixmap(), ImageComposer::ImageComposer(), ImageComposer::imagePos(), QListViewPrivate::indexToListViewItem(), qdesigner_internal::TabOrderEditor::indicatorRect(), QVFb::init(), QGLFramebufferObjectPrivate::init(), QListViewPrivate::initBspTree(), QListViewPrivate::initDynamicLayout(), qdesigner_internal::WidgetFactory::initialize(), GLWidget::initPbuffer(), KAstTopLevel::KAstTopLevel(), TextEdit::keyPressEvent(), Q3ProgressDialog::layout(), QAbstractScrollAreaPrivate::layoutChildren(), Q3MainWindowLayout::layoutItems(), QListViewPrivate::mapToViewport(), QDockAreaLayoutInfo::maximumSize(), QWidget::maximumWidth(), QHeaderView::minimumSectionSize(), Q3MainWindowLayout::minimumSize(), QMainWindowLayout::minimumSize(), Q3DockWindow::minimumSize(), QDockWidgetLayout::minimumSize(), QDockAreaLayoutInfo::minimumSize(), Q3DateTimeEdit::minimumSizeHint(), QMenuBar::minimumSizeHint(), QTabWidget::minimumSizeHint(), Q3DockWindow::minimumSizeHint(), QWidget::minimumWidth(), Q3TextTable::minimumWidth(), qdesigner_internal::QtColorLinePrivate::mouseMoveEvent(), qdesigner_internal::QtGradientStopsWidget::mouseMoveEvent(), qdesigner_internal::QtGradientWidget::mouseMoveEvent(), qdesigner_internal::QtGradientWidget::mousePressEvent(), QDateTimeEdit::mousePressEvent(), QListView::moveCursor(), QListViewPrivate::moveItem(), operator<<(), Oubliette::Oubliette(), OublietteLevel::OublietteLevel(), Q3CheckTableItem::paint(), QFontFamilyDelegate::paint(), QGraphicsSvgItem::paint(), Q3Table::paintEmptyArea(), ColorDock::paintEvent(), qdesigner_internal::QtColorLinePrivate::paintEvent(), qdesigner_internal::QtGradientWidget::paintEvent(), qdesigner_internal::QtGradientStopsWidget::paintEvent(), QGraphicsView::paintEvent(), GLWidget::paintGL(), Q3Header::paintSectionLabel(), QCommonStyle::pixelMetric(), QStyleSheetStyle::pixelMetric(), QPixmapIconEngine::pixmap(), QMenu::popup(), Q3ComboBox::popup(), QToolButtonPrivate::popupTimerDone(), ScribbleArea::print(), ImageViewer::print(), QPixmap::QPixmap(), QRect::QRect(), qSmartMinSize(), QWorkspaceChild::QWorkspaceChild(), read_jpeg_image(), QGraphicsViewPrivate::recalculateContentSize(), QComboBoxPrivate::recomputeSizeHint(), QDockWidgetPrivate::relayout(), QGraphicsView::render(), QGraphicsScene::render(), MainWindow::renderIntoPixmap(), Q3TextTable::resize(), QListView::resizeEvent(), QTextEdit::resizeEvent(), ArthurFrame::resizeEvent(), Q3DateTimeEdit::resizeEvent(), Q3ListBox::resizeEvent(), PreviewView::resizeEvent(), QExpandingLineEdit::resizeToContents(), RenderThread::run(), QImage::scaled(), QPixmap::scaled(), QDesktopWidget::screenNumber(), Q3TableHeader::sectionLabelChanged(), QHeaderView::sectionSizeFromContents(), Q3Header::sectionSizeHint(), QHeaderView::sectionSizeHint(), QWidgetItem::setGeometry(), BorderLayout::setGeometry(), QMainWindowLayout::setGeometry(), Spacer::setOrientation(), Q3Header::setSectionSizeAndHeight(), OublietteLevel::setTile(), QBoxLayoutPrivate::setupGeom(), QGridLayoutPrivate::setupLayoutData(), QPrintDialogPrivate::setupPrinter(), qdesigner_internal::SizeProperty::setValue(), shrink_extend(), QLabelPrivate::sizeForWidth(), QMotifStyle::sizeFromContents(), QCommonStyle::sizeFromContents(), QWindowsStyle::sizeFromContents(), Q3Table::sizeHint(), QProgressDialog::sizeHint(), QMenuBar::sizeHint(), QTabWidget::sizeHint(), QDockAreaLayoutInfo::sizeHint(), QCheckBox::sizeHint(), Q3DateTimeEdit::sizeHint(), Q3Header::sizeHint(), qdesigner_internal::FormWindow::sizeHint(), Q3ProgressDialog::sizeHint(), Q3DockWindow::sizeHint(), Q3CheckTableItem::sizeHint(), QRadioButton::sizeHint(), QPushButton::sizeHint(), QMainWindowLayout::sizeHint(), Button::sizeHint(), Q3ComboBox::sizeHint(), QToolBoxButton::sizeHint(), QScrollArea::sizeHint(), QDockWidgetLayout::sizeHint(), Q3MainWindowLayout::sizeHint(), Q3ScrollView::sizeHint(), QToolButton::sizeHint(), QListViewPrivate::snapToGrid(), QWindowsXPStyle::subControlRect(), QMotifStyle::subControlRect(), QCommonStyle::subControlRect(), QCleanlooksStyle::subControlRect(), QDockAreaLayoutInfo::tabContentRect(), QTabBar::tabSizeHint(), QItemDelegatePrivate::textLayoutBounds(), OublietteLevel::tile(), QListView::updateGeometries(), Q3Table::updateGeometries(), Q3FileDialog::updateGeometries(), QTableView::updateGeometries(), QMenuBarPrivate::updateGeometries(), QScrollAreaPrivate::updateScrollBars(), QTreeViewPrivate::updateScrollBars(), Q3ScrollView::updateScrollBars(), QMessageBoxPrivate::updateSize(), QWorkspacePrivate::updateWorkspace(), Q3ScrollViewData::viewportResized(), Q3TextEdit::viewportResizeEvent(), Q3ScrollView::viewportSize(), SvgNativeView::wheelEvent(), SvgGLView::wheelEvent(), SvgRasterView::wheelEvent(), OublietteLevel::width(), Q3ListViewItem::width(), Q3ListBoxItem::width(), Q3IconViewItem::width(), Q3ListBoxPixmap::width(), QSvgTinyDocument::width(), Q3ListView::widthChanged(), Window::Window(), and OublietteLevel::~OublietteLevel().

00105 { return wd; }

int QSize::height (  )  const [inline]

Returns the height.

See also:
width(), setHeight()

Definition at line 107 of file qsize.h.

References ht.

Referenced by QTextEditPrivate::_q_adjustScrollbars(), QPushButtonPrivate::_q_popupPressed(), QWorkspacePrivate::_q_showOperationMenu(), QLayout::activate(), QPixmapIconEngine::actualSize(), QGridLayoutPrivate::addData(), QGridLayoutPrivate::addHfwData(), QView3DWidget::addWidget(), Q3Table::adjustRow(), QWorkspaceChild::adjustToFullscreen(), QSvgTinyDocument::adjustWindowBounds(), QStyle::alignedRect(), QLayout::alignmentRect(), QDockAreaLayoutInfo::apply(), Q3IconView::arrangeItemsInGrid(), Q3ScrollViewData::autoResizeHint(), QBalloonTip::balloon(), QWorkspaceChild::baseSize(), QRenderRule::boxSize(), Dialog::buttonsOrientationChanged(), QMenuBarPrivate::calcActionRects(), QMenuPrivate::calcActionRects(), BorderLayout::calculateSize(), QWorkspace::cascade(), ColorDock::changeSizeHints(), Q3ToolBar::checkForExtension(), QVFb::chooseSize(), QLayout::closestAcceptableSize(), QAbstractFormBuilder::createDom(), Q3ToolBar::createPopup(), decorationFromDomWidget(), QListViewPrivate::doDynamicLayout(), QItemDelegate::doLayout(), Q3ListBox::doLayout(), FlowLayout::doLayout(), QListViewPrivate::doStaticLayout(), QListViewPrivate::draggedItemsDelta(), QRenderRule::drawBorder(), QCommonStyle::drawControl(), QStatusBar::event(), HoverPoints::eventFilter(), expandedSize(), QBitmap::fromData(), genIcon(), QDockWidgetLayout::getGrid(), QRenderRule::getRadii(), qdesigner_internal::QtColorLinePrivate::gradientPixmap(), Q3IconViewItem::height(), Q3ListBoxItem::height(), OublietteLevel::height(), QSvgTinyDocument::height(), QMenuBar::heightForWidth(), QBoxLayoutItem::hfw(), qdesigner_internal::QtColorLinePrivate::hueGradientPixmap(), ImageComposer::imagePos(), qdesigner_internal::TabOrderEditor::indicatorRect(), QVFb::init(), QGLFramebufferObjectPrivate::init(), QListViewPrivate::initBspTree(), QListViewPrivate::initDynamicLayout(), qdesigner_internal::WidgetFactory::initialize(), GLWidget::initPbuffer(), QProgressDialogPrivate::layout(), Q3ProgressDialog::layout(), QAbstractScrollAreaPrivate::layoutChildren(), QListViewPrivate::mapToViewport(), QWidget::maximumHeight(), QDockAreaLayoutInfo::maximumSize(), QBoxLayoutItem::mhfw(), QWidget::minimumHeight(), QHeaderView::minimumSectionSize(), Q3MainWindowLayout::minimumSize(), QMainWindowLayout::minimumSize(), Q3DockWindow::minimumSize(), QDockWidgetLayout::minimumSize(), QDockAreaLayoutInfo::minimumSize(), QTabBar::minimumSizeHint(), Q3DateTimeEdit::minimumSizeHint(), QMenuBar::minimumSizeHint(), QLabel::minimumSizeHint(), QTabWidget::minimumSizeHint(), Q3DockWindow::minimumSizeHint(), qdesigner_internal::QtColorLinePrivate::mouseMoveEvent(), qdesigner_internal::QtGradientWidget::mouseMoveEvent(), qdesigner_internal::QtGradientWidget::mousePressEvent(), QDateTimeEdit::mousePressEvent(), QListView::moveCursor(), QListViewPrivate::moveItem(), operator<<(), Oubliette::Oubliette(), OublietteLevel::OublietteLevel(), Q3CheckTableItem::paint(), QGraphicsSvgItem::paint(), Q3Table::paintEmptyArea(), ColorDock::paintEvent(), qdesigner_internal::QtColorLinePrivate::paintEvent(), qdesigner_internal::QtGradientWidget::paintEvent(), qdesigner_internal::QtGradientStopsWidget::paintEvent(), QGraphicsView::paintEvent(), GLWidget::paintGL(), Q3Header::paintSectionLabel(), PathStrokeWidget::PathStrokeWidget(), QCommonStyle::pixelMetric(), QStyleSheetStyle::pixelMetric(), QPixmapIconEngine::pixmap(), QMenu::popup(), QToolButtonPrivate::popupTimerDone(), ScribbleArea::print(), ImageViewer::print(), Q3FileDialogQFileListView::Q3FileDialogQFileListView(), QFileListBox::QFileListBox(), QPixmap::QPixmap(), QRect::QRect(), qSmartMinSize(), QWorkspaceChild::QWorkspaceChild(), read_jpeg_image(), QGraphicsViewPrivate::recalculateContentSize(), QComboBoxPrivate::recomputeSizeHint(), QStatusBar::reformat(), QDockWidgetPrivate::relayout(), QTextEditPrivate::relayoutDocument(), QGraphicsScene::render(), MainWindow::renderIntoPixmap(), QListView::resizeEvent(), QTextEdit::resizeEvent(), ArthurFrame::resizeEvent(), Q3ListBox::resizeEvent(), PreviewView::resizeEvent(), QWorkspaceChild::resizeEvent(), RenderThread::run(), QImage::scaled(), QPixmap::scaled(), Q3TableHeader::sectionLabelChanged(), QHeaderView::sectionSizeFromContents(), Q3Header::sectionSizeHint(), QHeaderView::sectionSizeHint(), QWidgetItem::setGeometry(), BorderLayout::setGeometry(), QMainWindowLayout::setGeometry(), Spacer::setOrientation(), Q3Header::setSectionSizeAndHeight(), OublietteLevel::setTile(), QBoxLayoutPrivate::setupGeom(), QGridLayoutPrivate::setupHfwLayoutData(), QGridLayoutPrivate::setupLayoutData(), QPrintDialogPrivate::setupPrinter(), qdesigner_internal::SizeProperty::setValue(), QCompleterPrivate::showPopup(), QComboBox::showPopup(), shrink_extend(), QWindowsXPStyle::sizeFromContents(), QMotifStyle::sizeFromContents(), QCommonStyle::sizeFromContents(), QPlastiqueStyle::sizeFromContents(), QWindowsStyle::sizeFromContents(), Q3Table::sizeHint(), QProgressDialog::sizeHint(), QMenuBar::sizeHint(), QTabWidget::sizeHint(), QDockAreaLayoutInfo::sizeHint(), QCheckBox::sizeHint(), Q3DateTimeEdit::sizeHint(), Q3Header::sizeHint(), qdesigner_internal::FormWindow::sizeHint(), Q3ProgressDialog::sizeHint(), Q3DockWindow::sizeHint(), Q3CheckTableItem::sizeHint(), QRadioButton::sizeHint(), QPushButton::sizeHint(), QMainWindowLayout::sizeHint(), Button::sizeHint(), QToolBoxButton::sizeHint(), QScrollArea::sizeHint(), QDockWidgetLayout::sizeHint(), Q3MainWindowLayout::sizeHint(), Q3ScrollView::sizeHint(), QToolButton::sizeHint(), QListViewPrivate::snapToGrid(), QWindowsXPStyle::subControlRect(), QMotifStyle::subControlRect(), QCommonStyle::subControlRect(), QDockAreaLayoutInfo::tabContentRect(), QTabBar::tabSizeHint(), OublietteLevel::tile(), QListView::updateGeometries(), Q3Table::updateGeometries(), QTreeView::updateGeometries(), Q3FileDialog::updateGeometries(), QTableView::updateGeometries(), QScrollAreaPrivate::updateScrollBars(), QTreeViewPrivate::updateScrollBars(), Q3ScrollView::updateScrollBars(), QWorkspacePrivate::updateWorkspace(), Q3ScrollViewData::viewportResized(), Q3TextEdit::viewportResizeEvent(), Q3ScrollView::viewportSize(), SvgNativeView::wheelEvent(), SvgGLView::wheelEvent(), SvgRasterView::wheelEvent(), and OublietteLevel::~OublietteLevel().

00108 { return ht; }

void QSize::setWidth ( int  width  )  [inline]

Sets the width to the given width.

See also:
rwidth(), width(), setHeight()

Definition at line 110 of file qsize.h.

References wd.

Referenced by QLayout::activate(), QRenderRule::boxSize(), QMenuBarPrivate::calcActionRects(), QMenuPrivate::calcActionRects(), expandedSize(), Q3DockWindow::minimumSize(), QMenuBar::minimumSizeHint(), Q3DockWindow::minimumSizeHint(), Q3Table::paintEmptyArea(), QComboBoxPrivate::recomputeSizeHint(), PreviewView::resizeEvent(), Q3DockWindow::setFixedExtentWidth(), QMainWindowLayout::setGeometry(), QSvgTinyDocument::setWidth(), QMotifStyle::sizeFromContents(), QCommonStyle::sizeFromContents(), QCleanlooksStyle::sizeFromContents(), QWindowsStyle::sizeFromContents(), Q3Table::sizeHint(), QMenuBar::sizeHint(), qdesigner_internal::FormWindow::sizeHint(), Q3DockWindow::sizeHint(), Q3CheckTableItem::sizeHint(), QScrollArea::sizeHint(), Q3ScrollView::sizeHint(), QFontComboBox::sizeHint(), QToolButton::sizeHint(), QMotifStyle::subControlRect(), QCommonStyle::subControlRect(), QCleanlooksStyle::subControlRect(), QETWidget::translateConfigEvent(), and Q3FileDialog::updateGeometries().

00111 { wd = w; }

void QSize::setHeight ( int  height  )  [inline]

Sets the height to the given height.

See also:
rheight(), height(), setWidth()

Definition at line 113 of file qsize.h.

References ht.

Referenced by QTextEditPrivate::_q_adjustScrollbars(), QLayout::activate(), QRenderRule::boxSize(), QMenuBarPrivate::calcActionRects(), QMenuPrivate::calcActionRects(), QLayout::closestAcceptableSize(), QItemDelegate::doLayout(), expandedSize(), QProgressDialogPrivate::layout(), Q3ProgressDialog::layout(), Q3DockWindow::minimumSize(), QMenuBar::minimumSizeHint(), Q3DockWindow::minimumSizeHint(), Q3Table::paintEmptyArea(), QMenu::popup(), QComboBoxPrivate::recomputeSizeHint(), PreviewView::resizeEvent(), Q3DockWindow::setFixedExtentHeight(), QMainWindowLayout::setGeometry(), QSvgTinyDocument::setHeight(), QGridLayoutPrivate::setupHfwLayoutData(), QStyleSheetStyle::sizeFromContents(), QWindowsXPStyle::sizeFromContents(), ArthurStyle::sizeFromContents(), QCommonStyle::sizeFromContents(), QCleanlooksStyle::sizeFromContents(), QPlastiqueStyle::sizeFromContents(), QWindowsStyle::sizeFromContents(), Q3Table::sizeHint(), QMenuBar::sizeHint(), qdesigner_internal::FormWindow::sizeHint(), Q3DockWindow::sizeHint(), QScrollArea::sizeHint(), Q3ScrollView::sizeHint(), QMotifStyle::subControlRect(), QCommonStyle::subControlRect(), QCleanlooksStyle::subControlRect(), and QETWidget::translateConfigEvent().

00114 { ht = h; }

void QSize::transpose (  ) 

Swaps the width and height values.

See also:
setWidth(), setHeight()

Definition at line 146 of file qsize.cpp.

References ht, and wd.

Referenced by QProgressBar::sizeHint(), and QTabBar::tabSizeHint().

00147 {
00148     int tmp = wd;
00149     wd = ht;
00150     ht = tmp;
00151 }

void QSize::scale ( int  width,
int  height,
Qt::AspectRatioMode  mode 
) [inline]

Scales the size to a rectangle with the given width and height, according to the specified mode:

If mode is Qt::IgnoreAspectRatio, the size is set to (width, height). If mode is Qt::KeepAspectRatio, the current size is scaled to a rectangle as large as possible inside (width, height), preserving the aspect ratio. If mode is Qt::KeepAspectRatioByExpanding, the current size is scaled to a rectangle as small as possible outside (width, height), preserving the aspect ratio.

Example:

        QSize t1(10, 12);
        t1.scale(60, 60, Qt::IgnoreAspectRatio);
        // t1 is (60, 60)

        QSize t2(10, 12);
        t2.scale(60, 60, Qt::KeepAspectRatio);
        // t2 is (50, 60)

        QSize t3(10, 12);
        t3.scale(60, 60, Qt::KeepAspectRatioByExpanding);
        // t3 is (60, 72)

See also:
setWidth(), setHeight()

Definition at line 116 of file qsize.h.

References QSize().

Referenced by QPixmapIconEngine::actualSize(), QPixmapIconEngine::pixmap(), ScribbleArea::print(), ImageViewer::print(), Screenshot::resizeEvent(), QImage::scaled(), and QPixmap::scaled().

00117 { scale(QSize(w, h), mode); }

Here is the call graph for this function:

void QSize::scale ( const QSize size,
Qt::AspectRatioMode  mode 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Scales the size to a rectangle with the given size, according to the specified mode.

Definition at line 192 of file qsize.cpp.

References ht, Qt::IgnoreAspectRatio, Qt::KeepAspectRatio, s, and wd.

00193 {
00194     if (mode == Qt::IgnoreAspectRatio) {
00195         wd = s.wd;
00196         ht = s.ht;
00197     } else {
00198         bool useHeight;
00199         int rw = qint32(qint64(s.ht) * qint64(wd) / qint64(ht));
00200 
00201         if (mode == Qt::KeepAspectRatio) {
00202             useHeight = (rw <= s.wd);
00203         } else { // mode == Qt::KeepAspectRatioByExpanding
00204             useHeight = (rw >= s.wd);
00205         }
00206 
00207         if (useHeight) {
00208             wd = rw;
00209             ht = s.ht;
00210         } else {
00211             ht = qint32(qint64(s.wd) * qint64(ht) / qint64(wd));
00212             wd = s.wd;
00213         }
00214     }
00215 }

QSize QSize::expandedTo ( const QSize otherSize  )  const [inline]

Returns a size holding the maximum width and height of this size and the given otherSize.

See also:
boundedTo(), scale()

Definition at line 165 of file qsize.h.

References ht, qMax(), QSize(), and wd.

Referenced by QWorkspace::cascade(), QLayout::closestAcceptableSize(), Q3MainWindowLayout::minimumSize(), Q3DockWindow::minimumSize(), QTabBar::minimumSizeHint(), QMenuBar::minimumSizeHint(), Q3WidgetStack::minimumSizeHint(), QTabWidget::minimumSizeHint(), QGroupBox::minimumSizeHint(), QAbstractSpinBox::minimumSizeHint(), Q3DockWindow::minimumSizeHint(), ScribbleArea::openImage(), positionRect(), QStyleSheetBorderData::QStyleSheetBorderData(), QWorkspaceChild::QWorkspaceChild(), QComboBoxPrivate::recomputeSizeHint(), qdesigner_internal::BreakLayoutCommand::redo(), QWidgetItem::setGeometry(), QBoxLayoutPrivate::setupGeom(), QWorkspaceChild::showShaded(), QStyleSheetStyle::sizeFromContents(), QSplitterHandle::sizeHint(), Q3TableItem::sizeHint(), QMenuBar::sizeHint(), QCheckBox::sizeHint(), QTabWidget::sizeHint(), Q3Header::sizeHint(), Q3WidgetStack::sizeHint(), Q3DockWindow::sizeHint(), QWorkspaceChild::sizeHint(), QAbstractSpinBox::sizeHint(), QDial::sizeHint(), QScrollBar::sizeHint(), QTabBar::sizeHint(), Q3TextEdit::sizeHint(), QDateTimeEdit::sizeHint(), QToolBoxButton::sizeHint(), QSlider::sizeHint(), QWidgetItem::sizeHint(), Q3ScrollView::sizeHint(), Q3ComboTableItem::sizeHint(), QMotifStyle::subControlRect(), QCommonStyle::subControlRect(), and QWorkspace::tile().

00166 {
00167     return QSize(qMax(wd,otherSize.wd), qMax(ht,otherSize.ht));
00168 }

Here is the call graph for this function:

QSize QSize::boundedTo ( const QSize otherSize  )  const [inline]

Returns a size holding the minimum width and height of this size and the given otherSize.

See also:
expandedTo(), scale()

Definition at line 170 of file qsize.h.

References ht, qMin(), QSize(), and wd.

Referenced by Q3ScrollViewData::autoResizeHint(), QItemDelegate::doLayout(), QTabWidgetPrivate::getStyleOption(), QWidgetItem::setGeometry(), QBoxLayoutPrivate::setupGeom(), QWellArray::sizeHint(), QWorkspaceChild::sizeHint(), QScrollArea::sizeHint(), Q3ScrollView::sizeHint(), and Q3ScrollViewData::viewportResized().

00171 {
00172     return QSize(qMin(wd,otherSize.wd), qMin(ht,otherSize.ht));
00173 }

Here is the call graph for this function:

int & QSize::rwidth (  )  [inline]

Returns a reference to the width.

Using a reference makes it possible to manipulate the width directly. For example:

        QSize size(100, 10);
        size.rwidth() += 20;

        // size becomes (120,10)

See also:
rheight(), setWidth()

Definition at line 119 of file qsize.h.

References wd.

Referenced by BorderLayout::calculateSize(), QItemDelegate::doLayout(), QDockAreaLayoutInfo::maximumSize(), QAbstractScrollArea::maximumViewportSize(), QDockAreaLayoutInfo::minimumSize(), QLabel::minimumSizeHint(), Q3WidgetStack::minimumSizeHint(), operator>>(), QComboBoxPrivate::recomputeSizeHint(), QHeaderView::sectionSizeFromContents(), QMotifStyle::sizeFromContents(), QPlastiqueStyle::sizeFromContents(), Q3WidgetStack::sizeHint(), QDockAreaLayoutInfo::sizeHint(), Button::sizeHint(), and SortingBox::updateButtonGeometry().

00120 { return wd; }

int & QSize::rheight (  )  [inline]

Returns a reference to the height.

Using a reference makes it possible to manipulate the height directly. For example:

        QSize size(100, 10);
        size.rheight() += 5;

        // size becomes (100,15)

See also:
rwidth(), setHeight()

Definition at line 122 of file qsize.h.

References ht.

Referenced by BorderLayout::calculateSize(), QDockAreaLayoutInfo::maximumSize(), QAbstractScrollArea::maximumViewportSize(), QDockAreaLayoutInfo::minimumSize(), QLabel::minimumSizeHint(), Q3WidgetStack::minimumSizeHint(), operator>>(), QTipLabel::QTipLabel(), QHeaderView::sectionSizeFromContents(), QPlastiqueStyle::sizeFromContents(), Q3WidgetStack::sizeHint(), QDockAreaLayoutInfo::sizeHint(), Button::sizeHint(), QWorkspace::tile(), and SortingBox::updateButtonGeometry().

00123 { return ht; }

QSize & QSize::operator+= ( const QSize size  )  [inline]

Adds the given size to this size, and returns a reference to this size. For example:

        QSize s( 3, 7);
        QSize r(-1, 4);
        s += r;

        // s becomes (2,11)

Definition at line 125 of file qsize.h.

References ht, s, and wd.

00126 { wd+=s.wd; ht+=s.ht; return *this; }

QSize & QSize::operator-= ( const QSize size  )  [inline]

Subtracts the given size from this size, and returns a reference to this size. For example:

        QSize s( 3, 7);
        QSize r(-1, 4);
        s -= r;

        // s becomes (4,3)

Definition at line 128 of file qsize.h.

References ht, s, and wd.

00129 { wd-=s.wd; ht-=s.ht; return *this; }

QSize & QSize::operator *= ( qreal  factor  )  [inline]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Multiplies both the width and height by the given factor, and returns a reference to the size.

Note that the result is rounded to the nearest integer.

See also:
scale()

Definition at line 131 of file qsize.h.

References ht, qRound(), and wd.

00132 { wd = qRound(wd*c); ht = qRound(ht*c); return *this; }

Here is the call graph for this function:

QSize & QSize::operator/= ( qreal  divisor  )  [inline]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Divides both the width and height by the given divisor, and returns a reference to the size.

Note that the result is rounded to the nearest integer.

See also:
QSize::scale()

Definition at line 152 of file qsize.h.

References ht, qRound(), and wd.

00153 {
00154     Q_ASSERT(!qFuzzyCompare(c, 0));
00155     wd = qRound(wd/c); ht = qRound(ht/c);
00156     return *this;
00157 }

Here is the call graph for this function:


Friends And Related Function Documentation

bool operator== ( const QSize s1,
const QSize s2 
) [friend]

Returns true if s1 and s2 are equal; otherwise returns false.

Definition at line 134 of file qsize.h.

00135 { return s1.wd == s2.wd && s1.ht == s2.ht; }

bool operator!= ( const QSize s1,
const QSize s2 
) [friend]

Returns true if s1 and s2 are different; otherwise returns false.

Definition at line 137 of file qsize.h.

00138 { return s1.wd != s2.wd || s1.ht != s2.ht; }

const QSize operator+ ( const QSize s1,
const QSize s2 
) [friend]

Returns the sum of s1 and s2; each component is added separately.

Definition at line 140 of file qsize.h.

00141 { return QSize(s1.wd+s2.wd, s1.ht+s2.ht); }

const QSize operator- ( const QSize s1,
const QSize s2 
) [friend]

Returns s2 subtracted from s1; each component is subtracted separately.

Definition at line 143 of file qsize.h.

00144 { return QSize(s1.wd-s2.wd, s1.ht-s2.ht); }

const QSize operator * ( const QSize size,
qreal  factor 
) [friend]

Multiplies the given size by the given factor, and returns the result rounded to the nearest integer.

See also:
QSize::scale()

Definition at line 146 of file qsize.h.

00147 { return QSize(qRound(s.wd*c), qRound(s.ht*c)); }

const QSize operator * ( qreal  factor,
const QSize size 
) [friend]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Multiplies the given size by the given factor, and returns the result rounded to the nearest integer.

Definition at line 149 of file qsize.h.

00150 { return QSize(qRound(s.wd*c), qRound(s.ht*c)); }

const QSize operator/ ( const QSize size,
qreal  divisor 
) [friend]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Divides the given size by the given divisor, and returns the result rounded to the nearest integer.

See also:
QSize::scale()

Definition at line 159 of file qsize.h.

00160 {
00161     Q_ASSERT(!qFuzzyCompare(c, 0));
00162     return QSize(qRound(s.wd/c), qRound(s.ht/c));
00163 }

QDataStream & operator<< ( QDataStream stream,
const QSize size 
) [related]

Writes the given size to the given stream, and returns a reference to the stream.

See also:
{Format of the QDataStream Operators}

Definition at line 400 of file qsize.cpp.

00401 {
00402     if (s.version() == 1)
00403         s << (qint16)sz.width() << (qint16)sz.height();
00404     else
00405         s << (qint32)sz.width() << (qint32)sz.height();
00406     return s;
00407 }

QDataStream & operator>> ( QDataStream stream,
QSize size 
) [related]

Reads a size from the given stream into the given size, and returns a reference to the stream.

See also:
{Format of the QDataStream Operators}

Definition at line 419 of file qsize.cpp.

00420 {
00421     if (s.version() == 1) {
00422         qint16 w, h;
00423         s >> w;  sz.rwidth() = w;
00424         s >> h;  sz.rheight() = h;
00425     }
00426     else {
00427         qint32 w, h;
00428         s >> w;  sz.rwidth() = w;
00429         s >> h;  sz.rheight() = h;
00430     }
00431     return s;
00432 }


Member Data Documentation

int QSize::wd [private]

Definition at line 72 of file qsize.h.

Referenced by boundedTo(), expandedTo(), isEmpty(), isNull(), isValid(), operator *=(), operator+=(), operator-=(), operator/=(), QSize(), rwidth(), scale(), setWidth(), transpose(), and width().

int QSize::ht [private]

Definition at line 73 of file qsize.h.

Referenced by boundedTo(), expandedTo(), height(), isEmpty(), isNull(), isValid(), operator *=(), operator+=(), operator-=(), operator/=(), QSize(), rheight(), scale(), setHeight(), and transpose().


The documentation for this class was generated from the following files:
Generated on Thu Mar 15 18:55:05 2007 for Qt 4.2 User's Guide by  doxygen 1.5.1