QPoint Class Reference

#include <qpoint.h>

List of all members.


Detailed Description

The QPoint class defines a point in the plane using integer precision.

A point is specified by a x coordinate and an y coordinate which can be accessed using the x() and y() functions. The isNull() function returns true if both x and y are set to 0. The coordinates can be set (or altered) using the setX() and setY() functions, or alternatively the rx() and ry() functions which return references to the coordinates (allowing direct manipulation).

Given a point p, the following statements are all equivalent:

        QPoint p;

        p.setX(p.x() + 1);
        p += QPoint(1, 0);
        p.rx()++;

A QPoint object can also be used as a vector: Addition and subtraction are defined as for vectors (each component is added separately). A QPoint object can also be divided or multiplied by an int or a qreal.

In addition, the QPoint class provides the manhattanLength() function which gives an inexpensive approximation of the length of the QPoint object interpreted as a vector. Finally, QPoint objects can be streamed as well as compared.

See also:
QPointF, QPolygon

Definition at line 33 of file qpoint.h.

Public Member Functions

 QPoint ()
 QPoint (int xpos, int ypos)
bool isNull () const
int x () const
int y () const
void setX (int x)
void setY (int y)
int manhattanLength () const
int & rx ()
int & ry ()
QPointoperator+= (const QPoint &p)
QPointoperator-= (const QPoint &p)
QPointoperator *= (qreal c)
QPointoperator/= (qreal c)

Private Attributes

int xp
int yp

Friends

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

Related Functions

(Note that these are not member functions.)

QDataStreamoperator<< (QDataStream &stream, const QPoint &point)
QDataStreamoperator>> (QDataStream &stream, QPoint &point)


Constructor & Destructor Documentation

QPoint::QPoint (  )  [inline]

Constructs a null point, i.e. with coordinates (0, 0)

See also:
isNull()

Definition at line 90 of file qpoint.h.

References xp, and yp.

00091 { xp=0; yp=0; }

QPoint::QPoint ( int  x,
int  y 
) [inline]

Constructs a point with the given coordinates (x, y).

See also:
setX(), setY()

Definition at line 93 of file qpoint.h.

References xp, and yp.

00094 { xp = xpos; yp = ypos; }


Member Function Documentation

bool QPoint::isNull (  )  const [inline]

Returns true if both the x and y coordinates are set to 0, otherwise returns false.

Definition at line 96 of file qpoint.h.

References xp, and yp.

Referenced by Q3ListView::doAutoScroll(), QX11WindowSurface::flush(), QDesignerMenuBar::handleMouseMoveEvent(), QDesignerMenu::handleMouseMoveEvent(), qdesigner_internal::FormWindow::handleMouseMoveEvent(), QDesignerToolBar::handleMouseMoveEvent(), QTest::mouseEvent(), SvgWindow::mouseMoveEvent(), PreviewView::mouseMoveEvent(), QPainterPrivate::updateMatrix(), and MandelbrotWidget::updatePixmap().

00097 { return xp == 0 && yp == 0; }

int QPoint::x (  )  const [inline]

Returns the x coordinate of this point.

See also:
setX(), rx()

Definition at line 99 of file qpoint.h.

References xp.

Referenced by QPushButtonPrivate::_q_popupPressed(), OublietteLevel::addItemToTile(), Launcher::addVersionAndCopyright(), QLayoutSupport::adjustIndicator(), QDialog::adjustPosition(), QAnimationWriter::appendFrame(), QBalloonTip::balloon(), qdesigner_internal::FormWindowManager::beginDrag(), QPolygon::boundingRect(), Q3TextEdit::charAt(), QAccessibleComboBox::childAt(), QAccessibleWidget::childAt(), qdesigner_internal::classifyLine(), OublietteLevel::clearTileFlags(), Q3Table::contentsContextMenuEvent(), Q3ListView::contentsContextMenuEvent(), Q3Table::contentsDragEnterEvent(), Q3Table::contentsDragMoveEvent(), Q3Table::contentsMouseDoubleClickEvent(), Q3ListView::contentsMouseDoubleClickEvent(), Q3Table::contentsMouseMoveEvent(), Q3Table::contentsMousePressEventEx(), Q3ListView::contentsMousePressEventEx(), Q3Table::contentsMouseReleaseEvent(), Q3ListView::contentsMouseReleaseEventEx(), Q3ScrollView::contentsToViewport(), Q3Table::contentsToViewport2(), CreateETandAET(), QAbstractFormBuilder::createProperty(), QLineEdit::cursorPositionAt(), VariantDelegate::displayText(), QAbstractItemView::doAutoScroll(), Q3ListBox::doAutoScroll(), Q3IconView::doAutoScroll(), Q3Table::doAutoScroll(), dockPos(), QListViewPrivate::doDynamicLayout(), QWidgetResizeHandler::doResize(), QPolygonalProcessor::doSpans(), QListViewPrivate::doStaticLayout(), QColorWell::dragMoveEvent(), QLineEdit::dragMoveEvent(), Q3IconView::dragObject(), QPainterPrivate::draw_helper(), QCleanlooksStyle::drawComplexControl(), QPlastiqueStyle::drawComplexControl(), ArthurStyle::drawComplexControl(), QWindowsXPStyle::drawComplexControl(), QCleanlooksStyle::drawControl(), QWindowsStyle::drawControl(), QFrame::drawFrame(), Q3DockWindowResizeHandle::drawLine(), QPainter::drawPoints(), QPaintEngine::drawPoints(), QX11PaintEngine::drawPoints(), QCommonStyle::drawPrimitive(), QCleanlooksStyle::drawPrimitive(), QWindowsStyle::drawPrimitive(), QTreeView::drawRow(), Q3Canvas::drawViewArea(), QColorWell::dropEvent(), QLineEdit::dropEvent(), QLine::dx(), ellipseSpansClipped(), Q3TextTable::enterAt(), Q3IconView::eventFilter(), QDesignerTabWidget::eventFilter(), Oubliette::fillTile(), Q3IconViewPrivate::findContainers(), QX11WindowSurface::flush(), QRasterWindowSurface::flush(), QRasterPaintEngine::flush(), Q3ScrollView::focusNextPrevChild(), QPixelTool::grabScreen(), grabWidget_helper(), qdesigner_internal::FormWindow::gridPoint(), qdesigner_internal::FormWindow::handleArrowKeyEvent(), Q3IconView::handleItemChange(), Q3TextEdit::handleMouseMove(), Q3DockWindow::handleMove(), QCommonStyle::hitTestComplexControl(), QColorPicker::huePt(), PieView::indexAt(), QTableView::indexAt(), QTreeView::indexAt(), QListViewPrivate::indexToListViewItem(), qdesigner_internal::LayoutCommand::init(), qdesigner_internal::BreakLayoutCommand::init(), QMenu::internalDelayedPopup(), QListView::internalDrop(), Q3SimpleRichText::inText(), Q3ListView::itemAt(), Q3ListBox::itemAt(), QTreeViewPrivate::itemDecorationAt(), ItemEffect::ItemEffect(), Q3AccessibleTextEdit::itemRect(), QWidgetResizeHandler::keyPressEvent(), Oubliette::keyPressEvent(), QAbstractScrollAreaPrivate::layoutChildren(), qdesigner_internal::lineEntryPos(), QHeaderView::logicalIndexAt(), manhattanLength(), QWidget::mapFromGlobal(), QTextEditPrivate::mapToContents(), QLineEdit::mouseDoubleClickEvent(), Q3Header::mouseDoubleClickEvent(), qdesigner_internal::QtGradientStopsWidget::mouseDoubleClickEvent(), QMenuPrivate::mouseEventTaken(), BasicToolsPlugin::mouseMove(), QView3DWidget::mouseMoveEvent(), qdesigner_internal::QtColorLinePrivate::mouseMoveEvent(), qdesigner_internal::QtGradientStopsWidget::mouseMoveEvent(), SvgWindow::mouseMoveEvent(), QWidgetResizeHandler::mouseMoveEvent(), CannonField::mouseMoveEvent(), PreviewView::mouseMoveEvent(), QColorWell::mouseMoveEvent(), Q3Header::mouseMoveEvent(), QLineEdit::mouseMoveEvent(), qdesigner_internal::QtGradientWidget::mouseMoveEvent(), CharacterWidget::mouseMoveEvent(), qdesigner_internal::WidgetHandle::mouseMoveEvent(), QScrollBar::mouseMoveEvent(), QToolBarHandle::mouseMoveEvent(), Q3DockWindowResizeHandle::mouseMoveEvent(), QGraphicsView::mouseMoveEvent(), QComboBoxPrivateScroller::mouseMoveEvent(), QWellArray::mousePressEvent(), qdesigner_internal::QtGradientWidget::mousePressEvent(), qdesigner_internal::QtGradientStopsWidget::mousePressEvent(), QDateTimeEdit::mousePressEvent(), Q3Header::mousePressEvent(), QLineEdit::mousePressEvent(), QScrollBar::mousePressEvent(), Q3DateTimeEditor::mousePressEvent(), Q3DockWindowResizeHandle::mouseReleaseEvent(), PageCurl::mouseReleaseEvent(), qdesigner_internal::WidgetHandle::mouseReleaseEvent(), Q3Header::mouseReleaseEvent(), MandelbrotWidget::mouseReleaseEvent(), Q3IconViewItem::move(), QDragManager::move(), Q3IconViewItem::moveBy(), Q3DockArea::moveDockWindow(), QAbstractButtonPrivate::moveFocus(), QAccessibleWidget::navigate(), Q3IconView::neighbourItem(), qdesigner_internal::QtGradientStopsWidgetPrivate::newStop(), operator<<(), Q3TextEdit::optimDoAutoScroll(), Q3TextEdit::optimMousePressEvent(), Q3TextEdit::optimMouseReleaseEvent(), PathStrokeRenderer::paint(), QColorPicker::paintEvent(), QTableView::paintEvent(), TicTacToe::paintEvent(), MandelbrotWidget::paintEvent(), QPixelTool::paintEvent(), paintGrid(), qdesigner_internal::paintGround(), perp(), QSplitterHandlePrivate::pick(), QSplitterPrivate::pick(), pick(), QSliderPrivate::pick(), pick_perp(), QImage::pixel(), QImage::pixelIndex(), Q3TextCursor::place(), qdesigner_internal::pointAboveLine(), QMenu::popup(), Q3ComboBox::popup(), PtsToRegion(), Q3CanvasPixmap::Q3CanvasPixmap(), qDrawShadeLine(), QRect::QRect(), qt_cleanlooks_draw_gradient(), qt_cleanlooks_draw_mdibutton(), Q3AccessibleHeader::rect(), QAccessibleSpinBox::rect(), QAccessibleHeader::rect(), QAccessibleWidget::rect(), QAccessibleMenu::rect(), QAccessibleMenuBar::rect(), QAccessibleWidget::relationTo(), QDockWidgetPrivate::relayout(), QToolBar::resizeEvent(), QExpandingLineEdit::resizeToContents(), QWhatsThisPrivate::say(), OublietteView::scrollToCharacter(), Q3TableHeader::sectionWidthChanged(), QLineEditPrivate::sendMouseEventToInputContext(), QMainWindowLayout::setGeometry(), QHeaderView::setOffset(), QImage::setPixel(), OublietteLevel::setTile(), qdesigner_internal::Layout::setup(), qdesigner_internal::PointProperty::setValue(), QAbstractItemViewPrivate::shouldAutoScroll(), QCompleterPrivate::showPopup(), QComboBox::showPopup(), QWhatsThis::showText(), QListViewPrivate::snapToGrid(), Q3IconView::startDrag(), qdesigner_internal::QtGradientStopsWidgetPrivate::stopAt(), qdesigner_internal::QtGradientStopsWidgetPrivate::stopsAt(), CannonField::targetRect(), PuzzleWidget::targetSquare(), OublietteLevel::tile(), qdesigner_internal::SignalSlotConnection::toUi(), QSplitterPrivate::trans(), QPolygon::translate(), QPainter::translate(), QETWidget::translateMouseEvent(), qdesigner_internal::WidgetHandle::trySetGeometry(), Q3DockWindow::undock(), Oubliette::updateExplored(), QPainterPrivate::updateMatrix(), PathStrokeRenderer::updatePoints(), Q3DockWindow::updatePosition(), ControllerWindow::updatePreview(), Q3ScrollView::updateScrollBars(), OublietteLevel::updateTileFlags(), Q3ScrollView::viewportToContents(), Q3Table::viewportToContents2(), Oubliette::visualCursorPos(), QStyle::visualPos(), QApplication::widgetAt(), qdesigner_internal::WidgetBoxDnDItem::WidgetBoxDnDItem(), QAnimationWriterMNG::writeDEFI(), QPNGImageWriter::writeImage(), QAnimationWriterMNG::writeMOVE(), QVFbMouseLinuxTP::writeToPipe(), QLine::x1(), and QLine::x2().

00100 { return xp; }

int QPoint::y (  )  const [inline]

Returns the y coordinate of this point.

See also:
setY(), ry()

Definition at line 102 of file qpoint.h.

References yp.

Referenced by QPushButtonPrivate::_q_popupPressed(), OublietteLevel::addItemToTile(), QLayoutSupport::adjustIndicator(), QDialog::adjustPosition(), QAnimationWriter::appendFrame(), QBalloonTip::balloon(), qdesigner_internal::FormWindowManager::beginDrag(), QPolygon::boundingRect(), QAccessibleComboBox::childAt(), QAccessibleWidget::childAt(), qdesigner_internal::classifyLine(), OublietteLevel::clearTileFlags(), Q3Table::contentsContextMenuEvent(), Q3Table::contentsDragEnterEvent(), Q3Table::contentsDragMoveEvent(), Q3Table::contentsMouseDoubleClickEvent(), Q3ListView::contentsMouseMoveEvent(), Q3Table::contentsMouseMoveEvent(), Q3Table::contentsMousePressEventEx(), Q3ListView::contentsMousePressEventEx(), Q3Table::contentsMouseReleaseEvent(), Q3ListView::contentsMouseReleaseEventEx(), Q3ScrollView::contentsToViewport(), Q3Table::contentsToViewport2(), CreateETandAET(), QAbstractFormBuilder::createProperty(), VariantDelegate::displayText(), QAbstractItemView::doAutoScroll(), Q3ListView::doAutoScroll(), Q3ListBox::doAutoScroll(), Q3IconView::doAutoScroll(), Q3Table::doAutoScroll(), dockPos(), QListViewPrivate::doDynamicLayout(), QWidgetResizeHandler::doResize(), QListViewPrivate::doStaticLayout(), QColorWell::dragMoveEvent(), Q3IconView::dragObject(), QPainterPrivate::draw_helper(), QCleanlooksStyle::drawComplexControl(), QPlastiqueStyle::drawComplexControl(), QWindowsXPStyle::drawComplexControl(), QPlastiqueStyle::drawControl(), QCleanlooksStyle::drawControl(), QWindowsStyle::drawControl(), QCommonStyle::drawControl(), QFrame::drawFrame(), Q3DockWindowResizeHandle::drawLine(), QPainter::drawPoints(), QPaintEngine::drawPoints(), QX11PaintEngine::drawPoints(), QPaintEngine::drawPolygon(), QCommonStyle::drawPrimitive(), QCleanlooksStyle::drawPrimitive(), QWindowsStyle::drawPrimitive(), QTreeView::drawRow(), Q3Canvas::drawViewArea(), QColorWell::dropEvent(), QLine::dy(), ellipseSpansClipped(), Q3TextTable::enterAt(), Q3IconView::eventFilter(), QDesignerTabWidget::eventFilter(), Oubliette::fillTile(), Q3IconViewPrivate::findContainers(), QX11WindowSurface::flush(), QRasterWindowSurface::flush(), QRasterPaintEngine::flush(), Q3ScrollView::focusNextPrevChild(), QPixelTool::grabScreen(), grabWidget_helper(), qdesigner_internal::FormWindow::gridPoint(), qdesigner_internal::FormWindow::handleArrowKeyEvent(), Q3IconView::handleItemChange(), Q3TextEdit::handleMouseMove(), Q3DockWindow::handleMove(), PieView::indexAt(), QTableView::indexAt(), QTreeView::indexAt(), qdesigner_internal::LayoutCommand::init(), qdesigner_internal::BreakLayoutCommand::init(), QMenu::internalDelayedPopup(), Q3SimpleRichText::inText(), Q3ListView::itemAt(), Q3ListBox::itemAt(), QTreeViewPrivate::itemDecorationAt(), ItemEffect::ItemEffect(), Q3AccessibleTextEdit::itemRect(), QWidgetResizeHandler::keyPressEvent(), QMenu::keyPressEvent(), Oubliette::keyPressEvent(), QAbstractScrollAreaPrivate::layoutChildren(), qdesigner_internal::lineEntryPos(), QHeaderView::logicalIndexAt(), manhattanLength(), QMatrix::map(), QWidget::mapFromGlobal(), QTextEditPrivate::mapToContents(), Q3Header::mouseDoubleClickEvent(), QMenuPrivate::mouseEventTaken(), BasicToolsPlugin::mouseMove(), QView3DWidget::mouseMoveEvent(), qdesigner_internal::QtColorLinePrivate::mouseMoveEvent(), qdesigner_internal::QtGradientStopsWidget::mouseMoveEvent(), SvgWindow::mouseMoveEvent(), QWidgetResizeHandler::mouseMoveEvent(), CannonField::mouseMoveEvent(), PreviewView::mouseMoveEvent(), QColorWell::mouseMoveEvent(), Q3Header::mouseMoveEvent(), qdesigner_internal::QtGradientWidget::mouseMoveEvent(), CharacterWidget::mouseMoveEvent(), qdesigner_internal::WidgetHandle::mouseMoveEvent(), QScrollBar::mouseMoveEvent(), QToolBarHandle::mouseMoveEvent(), Q3DockWindowResizeHandle::mouseMoveEvent(), QGraphicsView::mouseMoveEvent(), QComboBoxPrivateScroller::mouseMoveEvent(), QWellArray::mousePressEvent(), qdesigner_internal::QtGradientWidget::mousePressEvent(), QDateTimeEdit::mousePressEvent(), Q3Header::mousePressEvent(), QScrollBar::mousePressEvent(), Q3DockWindowResizeHandle::mouseReleaseEvent(), PageCurl::mouseReleaseEvent(), qdesigner_internal::WidgetHandle::mouseReleaseEvent(), Q3Header::mouseReleaseEvent(), MandelbrotWidget::mouseReleaseEvent(), Q3IconViewItem::move(), QDragManager::move(), Q3IconViewItem::moveBy(), QAbstractButtonPrivate::moveFocus(), QAccessibleWidget::navigate(), Q3IconView::neighbourItem(), operator<<(), Q3TextEdit::optimDoAutoScroll(), PathStrokeRenderer::paint(), QColorPicker::paintEvent(), QTableView::paintEvent(), MandelbrotWidget::paintEvent(), TicTacToe::paintEvent(), QPixelTool::paintEvent(), paintGrid(), qdesigner_internal::paintGround(), Q3TextEdit::paragraphAt(), perp(), QSplitterHandlePrivate::pick(), QSplitterPrivate::pick(), pick(), QSliderPrivate::pick(), pick_perp(), QImage::pixel(), QImage::pixelIndex(), Q3TextCursor::place(), qdesigner_internal::pointAboveLine(), QMenu::popup(), Q3ComboBox::popup(), QAbstractItemViewPrivate::position(), PtsToRegion(), Q3CanvasPixmap::Q3CanvasPixmap(), qDrawShadeLine(), QRect::QRect(), qt_cleanlooks_draw_gradient(), Q3AccessibleHeader::rect(), QAccessibleSpinBox::rect(), QAccessibleHeader::rect(), QAccessibleWidget::rect(), QAccessibleMenu::rect(), QAccessibleMenuBar::rect(), QAccessibleWidget::relationTo(), QDockWidgetPrivate::relayout(), QExpandingLineEdit::resizeToContents(), QColorPicker::satPt(), QWhatsThisPrivate::say(), OublietteView::scrollToCharacter(), Q3TableHeader::sectionWidthChanged(), QMainWindowLayout::setGeometry(), QHeaderView::setOffset(), QImage::setPixel(), OublietteLevel::setTile(), qdesigner_internal::Layout::setup(), qdesigner_internal::PointProperty::setValue(), QAbstractItemViewPrivate::shouldAutoScroll(), QCompleterPrivate::showPopup(), QComboBox::showPopup(), QWhatsThis::showText(), QListViewPrivate::snapToGrid(), Q3IconView::startDrag(), qdesigner_internal::QtGradientStopsWidgetPrivate::stopAt(), qdesigner_internal::QtGradientStopsWidgetPrivate::stopsAt(), QStyleSheetStyle::subControlRect(), CannonField::targetRect(), PuzzleWidget::targetSquare(), OublietteLevel::tile(), qdesigner_internal::SignalSlotConnection::toUi(), QSplitterPrivate::trans(), QPolygon::translate(), QPainter::translate(), QETWidget::translateMouseEvent(), qdesigner_internal::WidgetHandle::trySetGeometry(), Q3DockWindow::undock(), Q3TextEdit::updateCursor(), Oubliette::updateExplored(), QPainterPrivate::updateMatrix(), PathStrokeRenderer::updatePoints(), Q3DockWindow::updatePosition(), ControllerWindow::updatePreview(), Q3ScrollView::updateScrollBars(), OublietteLevel::updateTileFlags(), Q3ScrollView::viewportToContents(), Q3Table::viewportToContents2(), Oubliette::visualCursorPos(), QStyle::visualPos(), QApplication::widgetAt(), qdesigner_internal::WidgetBoxDnDItem::WidgetBoxDnDItem(), QAnimationWriterMNG::writeDEFI(), QPNGImageWriter::writeImage(), QAnimationWriterMNG::writeMOVE(), QVFbMouseLinuxTP::writeToPipe(), QLine::y1(), and QLine::y2().

00103 { return yp; }

void QPoint::setX ( int  x  )  [inline]

Sets the x coordinate of this point to the given x coordinate.

See also:
x() setY()

Definition at line 105 of file qpoint.h.

References xp.

Referenced by QAbstractScrollAreaPrivate::contentsOffset(), QListViewPrivate::indexToListViewItem(), QListView::internalDrop(), qdesigner_internal::QtColorLinePrivate::mouseMoveEvent(), CannonField::mouseMoveEvent(), QToolBarHandle::mouseMoveEvent(), QDateTimeEdit::mousePressEvent(), Q3TextEdit::optimDoAutoScroll(), Q3TextCursor::place(), PolygonRegion(), QMenu::popup(), set_perp(), QCompleterPrivate::showPopup(), QComboBox::showPopup(), PathStrokeRenderer::updatePoints(), Q3DockWindow::updatePosition(), and ControllerWindow::updatePreview().

00106 { xp = xpos; }

void QPoint::setY ( int  y  )  [inline]

Sets the y coordinate of this point to the given y coordinate.

See also:
y() setX()

Definition at line 108 of file qpoint.h.

References yp.

Referenced by QAbstractScrollAreaPrivate::contentsOffset(), QListViewPrivate::indexToListViewItem(), QMatrix::map(), qdesigner_internal::QtColorLinePrivate::mouseMoveEvent(), CannonField::mouseMoveEvent(), QDateTimeEdit::mousePressEvent(), Q3TextEdit::optimDoAutoScroll(), Q3TextCursor::place(), PolygonRegion(), QMenu::popup(), set_perp(), QCompleterPrivate::showPopup(), PathStrokeRenderer::updatePoints(), Q3DockWindow::updatePosition(), and ControllerWindow::updatePreview().

00109 { yp = ypos; }

int QPoint::manhattanLength (  )  const

Returns the sum of the absolute values of x() and y(), traditionally known as the "Manhattan length" of the vector from the origin to the point. For example:

        QPoint oldPosition;

        MyWidget::mouseMoveEvent(QMouseEvent *event)
        {
            QPoint point = event->pos() - oldPosition;
            if (point.manhattanLength() > 3)
                // the mouse has moved more than 3 pixels since the oldPosition
        }

This is a useful, and quick to calculate, approximation to the true length:

        int trueManhattenLength = sqrt(pow(x(), 2) + pow(y(), 2));

The tradition of "Manhattan length" arises because such distances apply to travelers who can only travel on a rectangular grid, like the streets of Manhattan.

Definition at line 381 of file qpoint.cpp.

References x(), and y().

Referenced by QDesignerTabWidget::canMove(), and QAbstractScrollAreaPrivate::layoutChildren().

00382 {
00383     return qAbs(x())+qAbs(y());
00384 }

Here is the call graph for this function:

int & QPoint::rx (  )  [inline]

Returns a reference to the x coordinate of this point.

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

        QPoint p(1, 2);
        p.rx()--;   // p becomes (0, 2)

See also:
x() setX()

Definition at line 111 of file qpoint.h.

References xp.

Referenced by Q3ListView::contentsMousePressEventEx(), QCommonStyle::drawControl(), QTextDocumentLayoutPrivate::drawListItem(), QWidgetResizeHandler::keyPressEvent(), Oubliette::keyPressEvent(), QWidgetResizeHandler::mouseMoveEvent(), PreviewView::mousePressEvent(), SvgWindow::mousePressEvent(), Q3DockArea::moveDockWindow(), operator>>(), rperp(), rpick(), QPlastiqueStyle::subControlRect(), QCleanlooksStyle::subControlRect(), QETWidget::translateConfigEvent(), and QETWidget::translateMouseEvent().

00112 { return xp; }

int & QPoint::ry (  )  [inline]

Returns a reference to the y coordinate of this point.

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

        QPoint p(1, 2);
        p.ry()++;   // p becomes (1, 3)

See also:
y(), setY()

Definition at line 114 of file qpoint.h.

References yp.

Referenced by QWidgetResizeHandler::keyPressEvent(), Oubliette::keyPressEvent(), QWidgetResizeHandler::mouseMoveEvent(), PreviewView::mousePressEvent(), SvgWindow::mousePressEvent(), operator>>(), rperp(), rpick(), QPlastiqueStyle::subControlRect(), QCleanlooksStyle::subControlRect(), QETWidget::translateConfigEvent(), and QETWidget::translateMouseEvent().

00115 { return yp; }

QPoint & QPoint::operator+= ( const QPoint point  )  [inline]

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

        QPoint p( 3, 7);
        QPoint q(-1, 4);
        p += q;    // p becomes (2, 11)

See also:
operator-=()

Definition at line 117 of file qpoint.h.

References p, xp, and yp.

00118 { xp+=p.xp; yp+=p.yp; return *this; }

QPoint & QPoint::operator-= ( const QPoint point  )  [inline]

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

        QPoint p( 3, 7);
        QPoint q(-1, 4);
        p -= q;    // p becomes (4, 3)

See also:
operator+=()

Definition at line 120 of file qpoint.h.

References p, xp, and yp.

00121 { xp-=p.xp; yp-=p.yp; return *this; }

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

Multiplies this point's coordinates by the given factor, and returns a reference to this point. For example:

        QPoint p(-1, 4);
        p *= 2.5;    // p becomes (-3, 10)

Note that the result is rounded to the nearest integer as points are held as integers. Use QPointF for floating point accuracy.

See also:
operator/=()

Definition at line 123 of file qpoint.h.

References qRound(), xp, and yp.

00124 { xp = qRound(xp*c); yp = qRound(yp*c); return *this; }

Here is the call graph for this function:

QPoint & QPoint::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 x and y by the given divisor, and returns a reference to this point. For example:

        QPoint p(-3, 10);
        p /= 2.5;           // p becomes (-1, 4)

Note that the result is rounded to the nearest integer as points are held as integers. Use QPointF for floating point accuracy.

See also:
operator*=()

Definition at line 147 of file qpoint.h.

References qRound(), xp, and yp.

00148 {
00149     Q_ASSERT(!qFuzzyCompare(c, 0));
00150     xp = qRound(xp/c);
00151     yp = qRound(yp/c);
00152     return *this;
00153 }

Here is the call graph for this function:


Friends And Related Function Documentation

bool operator== ( const QPoint p1,
const QPoint p2 
) [friend]

Returns true if p1 and p2 are equal; otherwise returns false.

Definition at line 126 of file qpoint.h.

00127 { return p1.xp == p2.xp && p1.yp == p2.yp; }

bool operator!= ( const QPoint p1,
const QPoint p2 
) [friend]

Returns true if p1 and p2 are not equal; otherwise returns false.

Definition at line 129 of file qpoint.h.

00130 { return p1.xp != p2.xp || p1.yp != p2.yp; }

const QPoint operator+ ( const QPoint p1,
const QPoint p2 
) [friend]

Returns a QPoint object that is the sum of the given points, p1 and p2; each component is added separately.

See also:
QPoint::operator+=()

Definition at line 132 of file qpoint.h.

00133 { return QPoint(p1.xp+p2.xp, p1.yp+p2.yp); }

const QPoint operator- ( const QPoint p1,
const QPoint p2 
) [friend]

Returns a QPoint object that is formed by subtracting p2 from p1; each component is subtracted separately.

See also:
QPoint::operator-=()

Definition at line 135 of file qpoint.h.

00136 { return QPoint(p1.xp-p2.xp, p1.yp-p2.yp); }

const QPoint operator * ( const QPoint point,
qreal  factor 
) [friend]

Returns a copy of the given point multiplied by the given factor.

Note that the result is rounded to the nearest integer as points are held as integers. Use QPointF for floating point accuracy.

See also:
QPoint::operator*=()

Definition at line 138 of file qpoint.h.

00139 { return QPoint(qRound(p.xp*c), qRound(p.yp*c)); }

const QPoint operator * ( qreal  factor,
const QPoint point 
) [friend]

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

Returns a copy of the given point multiplied by the given factor.

Definition at line 141 of file qpoint.h.

00142 { return QPoint(qRound(p.xp*c), qRound(p.yp*c)); }

const QPoint operator- ( const QPoint point  )  [friend]

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

Returns a QPoint object that is formed by changing the sign of both components of the given point.

Equivalent to {QPoint(0,0) - point}.

Definition at line 144 of file qpoint.h.

00145 { return QPoint(-p.xp, -p.yp); }

const QPoint operator/ ( const QPoint point,
qreal  divisor 
) [friend]

Returns the QPoint formed by dividing both components of the given point by the given divisor.

Note that the result is rounded to the nearest integer as points are held as integers. Use QPointF for floating point accuracy.

See also:
QPoint::operator/=()

Definition at line 155 of file qpoint.h.

00156 {
00157     Q_ASSERT(!qFuzzyCompare(c, 0));
00158     return QPoint(qRound(p.xp/c), qRound(p.yp/c));
00159 }

QDataStream & operator<< ( QDataStream stream,
const QPoint point 
) [related]

Writes the given point to the given stream and returns a reference to the stream.

See also:
{Format of the QDataStream Operators}

Definition at line 319 of file qpoint.cpp.

00320 {
00321     if (s.version() == 1)
00322         s << (qint16)p.x() << (qint16)p.y();
00323     else
00324         s << (qint32)p.x() << (qint32)p.y();
00325     return s;
00326 }

QDataStream & operator>> ( QDataStream stream,
QPoint point 
) [related]

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

See also:
{Format of the QDataStream Operators}

Definition at line 338 of file qpoint.cpp.

00339 {
00340     if (s.version() == 1) {
00341         qint16 x, y;
00342         s >> x;  p.rx() = x;
00343         s >> y;  p.ry() = y;
00344     }
00345     else {
00346         qint32 x, y;
00347         s >> x;  p.rx() = x;
00348         s >> y;  p.ry() = y;
00349     }
00350     return s;
00351 }


Member Data Documentation

int QPoint::xp [private]

Definition at line 71 of file qpoint.h.

Referenced by isNull(), operator *=(), operator!=(), operator+(), operator+=(), operator-(), operator-=(), operator/=(), operator==(), QPoint(), rx(), setX(), and x().

int QPoint::yp [private]

Definition at line 72 of file qpoint.h.

Referenced by isNull(), operator *=(), operator!=(), operator+(), operator+=(), operator-(), operator-=(), operator/=(), operator==(), QPoint(), ry(), setY(), and y().


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