QRectF Class
QRectF クラスは、浮動小数点精度を用いて平面上の有限な矩形を定義します。詳細...
| ヘッダー: | #include <QRectF> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Core) target_link_libraries(mytarget PRIVATE Qt6::Core) |
| qmake: | QT += core |
- 継承されたメンバーを含む、すべてのメンバーの一覧
- QRectF はPainting クラスの一部です。
注:このクラスのすべての関数は再入可能である。
QRectF の比較
| カテゴリ | 比較可能な型 |
|---|---|
| 等価性 | QRectF |
| 等価性 | QRect. |
パブリック関数
| QRectF() | |
| QRectF(const QRect &rectangle) | |
| QRectF(const QPointF &topLeft, const QPointF &bottomRight) | |
| QRectF(const QPointF &topLeft, const QSizeF &size) | |
| QRectF(qreal x, qreal y, qreal width, qreal height) | |
| void | adjust(qreal dx1, qreal dy1, qreal dx2, qreal dy2) |
| QRectF | adjusted(qreal dx1, qreal dy1, qreal dx2, qreal dy2) const |
| qreal | bottom() const |
| QPointF | bottomLeft() const |
| QPointF | bottomRight() const |
| QPointF | center() const |
| bool | contains(const QPointF &point) const |
| bool | contains(const QRectF &rectangle) const |
| bool | contains(qreal x, qreal y) const |
| void | getCoords(qreal *x1, qreal *y1, qreal *x2, qreal *y2) const |
| void | getRect(qreal *x, qreal *y, qreal *width, qreal *height) const |
| qreal | height() const |
| QRectF | intersected(const QRectF &rectangle) const |
| bool | intersects(const QRectF &rectangle) const |
| bool | isEmpty() const |
| bool | isNull() const |
| bool | isValid() const |
| qreal | left() const |
| QRectF | marginsAdded(const QMarginsF &margins) const |
| QRectF | marginsRemoved(const QMarginsF &margins) const |
| void | moveBottom(qreal y) |
| void | moveBottomLeft(const QPointF &position) |
| void | moveBottomRight(const QPointF &position) |
| void | moveCenter(const QPointF &position) |
| void | moveLeft(qreal x) |
| void | moveRight(qreal x) |
| void | moveTo(qreal x, qreal y) |
| void | moveTo(const QPointF &position) |
| void | moveTop(qreal y) |
| void | moveTopLeft(const QPointF &position) |
| void | moveTopRight(const QPointF &position) |
| QRectF | normalized() const |
| qreal | right() const |
| void | setBottom(qreal y) |
| void | setBottomLeft(const QPointF &position) |
| void | setBottomRight(const QPointF &position) |
| void | setCoords(qreal x1, qreal y1, qreal x2, qreal y2) |
| void | setHeight(qreal height) |
| void | setLeft(qreal x) |
| void | setRect(qreal x, qreal y, qreal width, qreal height) |
| void | setRight(qreal x) |
| void | setSize(const QSizeF &size) |
| void | setTop(qreal y) |
| void | setTopLeft(const QPointF &position) |
| void | setTopRight(const QPointF &position) |
| void | setWidth(qreal width) |
| void | setX(qreal x) |
| void | setY(qreal y) |
| QSizeF | size() const |
| QRect | toAlignedRect() const |
| CGRect | toCGRect() const |
(since 6.5) emscripten::val | toDOMRect() const |
| QRect | toRect() const |
| qreal | top() const |
| QPointF | topLeft() const |
| QPointF | topRight() const |
| void | translate(qreal dx, qreal dy) |
| void | translate(const QPointF &offset) |
| QRectF | translated(qreal dx, qreal dy) const |
| QRectF | translated(const QPointF &offset) const |
| QRectF | transposed() const |
| QRectF | united(const QRectF &rectangle) const |
| qreal | width() const |
| qreal | x() const |
| qreal | y() const |
| QRectF | operator&(const QRectF &rectangle) const |
| QRectF & | operator&=(const QRectF &rectangle) |
| QRectF & | operator+=(const QMarginsF &margins) |
| QRectF & | operator-=(const QMarginsF &margins) |
| QRectF | operator|(const QRectF &rectangle) const |
| QRectF & | operator|=(const QRectF &rectangle) |
静的パブリックメンバー
| QRectF | fromCGRect(CGRect rect) |
(since 6.5) QRectF | fromDOMRect(emscripten::val domRect) |
関連する非メンバー
(since 6.8) bool | qFuzzyCompare(const QRectF &lhs, const QRectF &rhs) |
(since 6.8) bool | qFuzzyIsNull(const QRectF &rect) |
| bool | operator!=(const QRectF &lhs, const QRectF &rhs) |
| QRectF | operator+(const QRectF &lhs, const QMarginsF &rhs) |
| QRectF | operator+(const QMarginsF &lhs, const QRectF &rhs) |
| QRectF | operator-(const QRectF &lhs, const QMarginsF &rhs) |
| QDataStream & | operator<<(QDataStream &stream, const QRectF &rectangle) |
| bool | operator==(const QRectF &lhs, const QRectF &rhs) |
| QDataStream & | operator>>(QDataStream &stream, QRectF &rectangle) |
詳細な説明
矩形は通常、左上隅とサイズによって表現されます。QRectFのサイズ(幅と高さ)は、そのレンダリングの基礎となる数学的な矩形と常に等価です。
QRectF は、左、上、幅、高さの座標のセット、またはQPointF とQSizeF から構築することができます。以下のコードは、2 つの同一の矩形を作成します。
また、QRect から QRectF を作成する 3 つ目のコンストラクタと、この矩形の値に基づいてQRect オブジェクトを返す対応するtoRect() 関数もあります(返される矩形の座標は、最も近い整数に丸められていることに注意してください)。
QRectFクラスは、矩形のさまざまな座標を返す一連の関数を提供しており、これらを操作することが可能です。 また、QRectF には、さまざまな座標を基準として矩形を移動させる関数も用意されています。さらに、moveTo() 関数を使用すると、矩形の左上隅を指定された座標に固定したまま、矩形全体を移動させることができます。あるいは、translate() 関数を使用すると、現在の位置を基準として指定されたオフセット分だけ矩形を移動させることができ、translated() 関数を使用すると、この矩形の移動後のコピーが返されます。
size() 関数は、矩形の寸法を `QSizeF` として返します。寸法は、width() およびheight() 関数を使用して個別に取得することもできます。寸法を操作するには、setSize()、setWidth()、またはsetHeight() 関数を使用します。あるいは、setBottom() やsetRight() など、矩形の座標を設定する関数のいずれかを適用することで、サイズを変更することもできます。
contains() 関数は、指定された点が矩形の内側にあるかどうかを判定し、intersects() 関数は、この矩形が指定された矩形と交差する場合にtrue を返し(そうでない場合は false を返します)。QRectF クラスは、交差する矩形を返すintersected() 関数や、指定された矩形とこの矩形を囲む矩形を返すunited() 関数も提供しています:
isEmpty() 関数は、矩形の幅または高さが 0 以下である場合に `true ` を返します。空の矩形は無効であることに注意してください。isValid() 関数は、幅と高さの両方が 0 より大きい場合に `true ` を返します。一方、ヌル矩形(isNull() == true)は、幅と高さの両方が 0 に設定されています。
なお、QRect およびQRectFの定義の仕方のため、空のQRectFは本質的にQRect と同様に定義されています。
最後に、QRectF オブジェクトは比較できるだけでなく、ストリームとして出力することも可能です。
レンダリング
anti-aliased ペインタを使用する場合、QRectF の境界線は、数学的な長方形の境界線の両側に左右対称にレンダリングされます。しかし、エイリアシングされたペインタ(デフォルト)を使用する場合は、別のルールが適用されます。
この場合、幅 1 ピクセルのペンでレンダリングすると、QRectF の境界線は、数学的な長方形の境界線の右側および下側にレンダリングされます。
幅2ピクセルのペンでレンダリングする場合、境界線は数学的な長方形の中心で分割されます。これは、ペンの幅が偶数ピクセルに設定されている場合に常に当てはまります。一方、ペンの幅が奇数ピクセルに設定されている場合は、余分な1ピクセルが、1ピクセルの場合と同様に、数学的な長方形の右側および下側にレンダリングされます。
![]() | ![]() |
| 論理的な表現 | 幅1ピクセルのペン |
![]() | ![]() |
| 幅2ピクセルのペン | 3ピクセル幅のペン |
座標
QRectF クラスは、さまざまな矩形の座標を返す関数のコレクションを提供し、これらの座標の操作を可能にします。また、QRectF は、さまざまな座標系を基準として矩形を移動させる関数も提供します。
例えば、bottom()、setBottom()、moveBottom() といった関数があります。bottom()は、矩形の下端の y 座標を返し、setBottom() は、矩形の下辺を指定された y 座標に設定します(高さが変わる場合がありますが、矩形の上辺は決して変わりません)。また、moveBottom() は、矩形の下辺を指定された y 座標に固定したまま、サイズを変更せずに矩形全体を垂直方向に移動させます。

また、adjust() 関数を使用してこの矩形の座標にオフセットを追加したり、adjusted() 関数を使用して元の矩形を調整した新しい矩形を取得したりすることも可能です。幅または高さのいずれかが負の場合、normalized() 関数を使用して、角の位置が入れ替わった矩形を取得してください。
さらに、QRectF には、矩形の左上隅と右下隅の位置を取得する `getCoords()` 関数や、矩形の左上隅、幅、高さを取得する `getRect()` 関数が用意されています。`setCoords()` および `setRect()` 関数を使用すると、矩形の座標と寸法を一度に操作できます。
「 QRect 」および「QRegion 」も参照してください 。
メンバ関数のドキュメント
[constexpr noexcept] QRectF::QRectF()
ヌル矩形を生成します。
isNull()も参照してください 。
[constexpr noexcept] QRectF::QRectF(const QRect &rectangle)
指定されたQRect rectangle からQRectF矩形を生成します。
注:この関数は 、QRect::toRectF()と同様に、rectangle のsize()を保持し、そのbottomRight()の角座標は保持しません。
toRect() およびQRect::toRectF()も参照してください 。
[constexpr noexcept] QRectF::QRectF(const QPointF &topLeft, const QPointF &bottomRight)
指定されたtopLeft およびbottomRight の角を持つ長方形を作成します。
setTopLeft() およびsetBottomRight()も参照してください 。
[constexpr noexcept] QRectF::QRectF(const QPointF &topLeft, const QSizeF &size)
指定されたtopLeft の角と、指定されたsize を用いて長方形を構築します。
setTopLeft() およびsetSize()も参照してください 。
[constexpr noexcept] QRectF::QRectF(qreal x, qreal y, qreal width, qreal height)
(x,y)を左上隅とし、指定されたwidth およびheight を持つ長方形を作成します。すべての引数は有限でなければなりません。
setRect()も参照してください 。
[constexpr noexcept] void QRectF::adjust(qreal dx1, qreal dy1, qreal dx2, qreal dy2)
矩形の既存の座標に、それぞれdx1 、dy1 、dx2 、dy2 を加算します。すべてのパラメータは有限でなければなりません。
adjusted() およびsetRect()も参照してください 。
[constexpr noexcept] QRectF QRectF::adjusted(qreal dx1, qreal dy1, qreal dx2, qreal dy2) const
この矩形の既存の座標に、それぞれdx1 、dy1 、dx2 、dy2 を加えた新しい矩形を返します。すべてのパラメータは有限でなければなりません。
adjust()も参照してください 。
[constexpr noexcept] qreal QRectF::bottom() const
矩形の下辺の y 座標を返します。
setBottom()、bottomLeft()、およびbottomRight()も参照してください 。
[constexpr noexcept] QPointF QRectF::bottomLeft() const
矩形の左下隅の位置を返します。
setBottomLeft()、bottom()、およびleft()も参照してください 。
[constexpr noexcept] QPointF QRectF::bottomRight() const
矩形の右下隅の位置を返します。
setBottomRight()、bottom()、およびright()も参照してください 。
[constexpr noexcept] QPointF QRectF::center() const
矩形の中心点を返します。
moveCenter()も参照してください 。
[noexcept] bool QRectF::contains(const QPointF &point) const
指定されたpoint が矩形の内側または境界線上にある場合はtrue を返し、そうでない場合はfalse を返します。
intersects()も参照してください 。
[noexcept] bool QRectF::contains(const QRectF &rectangle) const
指定された `rectangle ` がこの矩形内にある場合は `true ` を返し、そうでない場合は `false` を返します。
これはオーバーロードされた関数です。
[noexcept] bool QRectF::contains(qreal x, qreal y) const
点 (x,y) が矩形の内側または境界線上にある場合は `true ` を返し、そうでない場合は `false` を返します。
これはオーバーロードされた関数です。
[static noexcept] QRectF QRectF::fromCGRect(CGRect rect)
CGRectrect からQRectF を作成します。
toCGRect()も参照してください 。
[static, since 6.5] QRectF QRectF::fromDOMRect(emscripten::val domRect)
DOMRect(https://www.w3.org/TR/geometry-1/)domRect をQRectF に変換します。渡されたパラメータが DOMRect でない場合、動作は未定義となります。
この関数は Qt 6.5 で導入されました。
toDOMRect()も参照してください 。
[constexpr] void QRectF::getCoords(qreal *x1, qreal *y1, qreal *x2, qreal *y2) const
矩形の左上隅の位置を *x1 および *y1 に、右下隅の位置を *x2 および *y2 に取得します。
setCoords() およびgetRect()も参照してください 。
[constexpr] void QRectF::getRect(qreal *x, qreal *y, qreal *width, qreal *height) const
矩形の左上隅の位置を *x および *y に、その寸法を *width および *height に抽出します。
setRect() およびgetCoords()も参照してください 。
[constexpr noexcept] qreal QRectF::height() const
矩形の高さを返します。
setHeight()、width()、およびsize()も参照してください 。
[noexcept] QRectF QRectF::intersected(const QRectF &rectangle) const
この矩形と、指定されたrectangle との共通部分を返します。なお、r.intersected(s) はr & s と同等であることに注意してください。

intersects()、united()、およびoperator&=()も参照してください 。
[noexcept] bool QRectF::intersects(const QRectF &rectangle) const
この矩形が指定されたrectangle と交差する場合(つまり、両者の間に空ではない重なり部分がある場合)、true を返し、そうでない場合はfalse を返します。
交差する矩形は、intersected() 関数を使用して取得できます。
contains()も参照してください 。
[constexpr noexcept] bool QRectF::isEmpty() const
矩形が空の場合は `true ` を返し、それ以外の場合は `false` を返します。
空の矩形は、width() <= 0 またはheight() <= 0 です。空の矩形は無効です(つまり、isEmpty() == !isValid() です)。
normalized() 関数を使用すると、角が入れ替わった矩形を取得できます。
isNull()、isValid()、およびnormalized()も参照してください 。
[constexpr noexcept] bool QRectF::isNull() const
矩形がヌル矩形の場合はtrue を返し、それ以外の場合はfalse を返します。
ヌル矩形とは、幅と高さの両方が 0 に設定されている矩形のことです。ヌル矩形は空であるため、無効です。
isEmpty() およびisValid()も参照してください 。
[constexpr noexcept] bool QRectF::isValid() const
矩形が有効な場合は `true ` を返し、そうでない場合は `false` を返します。
有効な矩形は、width() > 0 かつheight() > 0 です。なお、交差などの非自明な演算は、無効な矩形に対しては定義されていません。有効な矩形は空ではありません(すなわち、isValid() == !isEmpty() です)。
isNull()、isEmpty()、およびnormalized()も参照してください 。
[constexpr noexcept] qreal QRectF::left() const
矩形の左端の x 座標を返します。x() と同等です。
setLeft()、topLeft()、およびbottomLeft()も参照してください 。
[constexpr noexcept] QRectF QRectF::marginsAdded(const QMarginsF &margins) const
margins によって拡大された矩形を返します。
operator+=()、marginsRemoved()、およびoperator-=()も参照してください 。
[constexpr noexcept] QRectF QRectF::marginsRemoved(const QMarginsF &margins) const
矩形から「margins 」を削除し、そのサイズを縮小します。
marginsAdded()、operator+=()、およびoperator-=()も参照してください 。
[constexpr noexcept] void QRectF::moveBottom(qreal y)
矩形を垂直方向に移動させ、矩形の下端を指定された有限のy 座標に固定します。矩形のサイズは変更されません。
bottom()、setBottom()、およびmoveTop()も参照してください 。
[constexpr noexcept] void QRectF::moveBottomLeft(const QPointF &position)
指定されたposition を左下隅として、矩形を移動します。矩形のサイズは変更されません。
setBottomLeft()、moveBottom()、およびmoveLeft()も参照してください 。
[constexpr noexcept] void QRectF::moveBottomRight(const QPointF &position)
指定されたposition を右下隅として、矩形を移動します。矩形のサイズは変更されません。
setBottomRight()、moveBottom()、およびmoveRight()も参照してください 。
[constexpr noexcept] void QRectF::moveCenter(const QPointF &position)
指定されたposition の位置を中央点として、長方形を移動します。長方形のサイズは変更されません。
center()も参照してください 。
[constexpr noexcept] void QRectF::moveLeft(qreal x)
矩形を水平方向に移動させ、矩形の左端を指定された有限のx 座標に固定します。矩形のサイズは変更されません。
left()、setLeft()、およびmoveRight()も参照してください 。
[constexpr noexcept] void QRectF::moveRight(qreal x)
矩形を水平方向に移動させ、矩形の右端を指定された有限のx 座標に合わせます。矩形のサイズは変更されません。
right()、setRight()、およびmoveLeft()も参照してください 。
[constexpr noexcept] void QRectF::moveTo(qreal x, qreal y)
左上隅を指定された位置に固定したまま、矩形を移動します(x 、y )。矩形のサイズは変更されません。両方のパラメータは有限でなければなりません。
translate() およびmoveTopLeft()も参照してください 。
[constexpr noexcept] void QRectF::moveTo(const QPointF &position)
指定されたposition を左上隅として、矩形を移動します。
これはオーバーロードされた関数です。
[constexpr noexcept] void QRectF::moveTop(qreal y)
矩形を垂直方向に移動させ、矩形の上辺を指定された有限のy 座標に固定します。矩形のサイズは変更されません。
top()、setTop()、およびmoveBottom()も参照してください 。
[constexpr noexcept] void QRectF::moveTopLeft(const QPointF &position)
指定されたposition を左上隅として、矩形を移動します。矩形のサイズは変更されません。
setTopLeft()、moveTop()、およびmoveLeft()も参照してください 。
[constexpr noexcept] void QRectF::moveTopRight(const QPointF &position)
指定された座標position を右上隅として、矩形を移動します。矩形のサイズは変更されません。
setTopRight()、moveTop()、およびmoveRight()も参照してください 。
[noexcept] QRectF QRectF::normalized() const
正規化された矩形、すなわち、幅と高さが非負の矩形を返します。
width() < 0 の場合、この関数は左隅と右隅を入れ替え、height() < 0 の場合、上隅と下隅を入れ替えます。
isValid() およびisEmpty()も参照してください 。
[constexpr noexcept] qreal QRectF::right() const
矩形の右端のx座標を返します。
setRight()、topRight()、およびbottomRight()も参照してください 。
[constexpr noexcept] void QRectF::setBottom(qreal y)
矩形の下辺を、指定された有限のy 座標に設定します。高さが変わる場合がありますが、矩形の上辺が変わることはありません。
bottom() およびmoveBottom()も参照してください 。
[constexpr noexcept] void QRectF::setBottomLeft(const QPointF &position)
長方形の左下隅を、指定されたposition に設定します。サイズは変更される場合がありますが、長方形の右上隅は決して変更されません。
bottomLeft() およびmoveBottomLeft()も参照してください 。
[constexpr noexcept] void QRectF::setBottomRight(const QPointF &position)
長方形の右下隅を、指定されたposition に設定します。サイズは変更される場合がありますが、長方形の左上隅は決して変更されません。
bottomRight() およびmoveBottomRight()も参照してください 。
[constexpr noexcept] void QRectF::setCoords(qreal x1, qreal y1, qreal x2, qreal y2)
矩形の左上隅の座標を (x1,y1) に、右下隅の座標を (x2,y2) に設定します。すべてのパラメータは有限値でなければなりません。
getCoords() およびsetRect()も参照してください 。
[constexpr noexcept] void QRectF::setHeight(qreal height)
矩形の高さを、指定された有限の値height に設定します。下辺は変更されますが、上辺は変更されません。
height() およびsetSize()も参照してください 。
[constexpr noexcept] void QRectF::setLeft(qreal x)
矩形の左端を、指定された有限のx 座標に設定します。幅が変わる場合がありますが、矩形の右端が変わることはありません。
setX() と同等です。
left() およびmoveLeft()も参照してください 。
[constexpr noexcept] void QRectF::setRect(qreal x, qreal y, qreal width, qreal height)
矩形の左上隅の座標を (x,y) に設定し、そのサイズを指定されたwidth およびheight に設定します。すべてのパラメータは有限でなければなりません。
getRect() およびsetCoords()も参照してください 。
[constexpr noexcept] void QRectF::setRight(qreal x)
矩形の右端を、指定された有限のx 座標に設定します。幅が変わる場合がありますが、矩形の左端が変わることはありません。
right() およびmoveRight()も参照してください 。
[constexpr noexcept] void QRectF::setSize(const QSizeF &size)
矩形のサイズを、指定された有限のsize に設定します。左上隅の位置は変更されません。
size()、setWidth()、およびsetHeight()も参照してください 。
[constexpr noexcept] void QRectF::setTop(qreal y)
矩形の上辺を、指定された有限のy 座標に設定します。高さが変わる場合がありますが、矩形の下辺が変わることはありません。
setY() と同等です。
[constexpr noexcept] void QRectF::setTopLeft(const QPointF &position)
矩形の左上隅を、指定されたposition に設定します。サイズは変更される場合がありますが、矩形の右下隅は決して変更されません。
topLeft() およびmoveTopLeft()も参照してください 。
[constexpr noexcept] void QRectF::setTopRight(const QPointF &position)
長方形の右上隅を、指定されたposition に設定します。サイズは変更される場合がありますが、長方形の左下隅は決して変更されません。
topRight() およびmoveTopRight()も参照してください 。
[constexpr noexcept] void QRectF::setWidth(qreal width)
矩形の幅を、指定された有限のwidth に設定します。右端は変更されますが、左端は変更されません。
width() およびsetSize()も参照してください 。
[constexpr noexcept] void QRectF::setX(qreal x)
矩形の左端を、指定された有限のx 座標に設定します。幅が変わる場合がありますが、矩形の右端は決して変わりません。
setLeft() と同等です。
x()、setY()、およびsetTopLeft()も参照してください 。
[constexpr noexcept] void QRectF::setY(qreal y)
矩形の上辺を、指定された有限のy 座標に設定します。高さが変わる場合がありますが、矩形の下辺は決して変わりません。
setTop() と同等です。
y()、setX()、およびsetTopLeft()も参照してください 。
[constexpr noexcept] QSizeF QRectF::size() const
矩形のサイズを返します。
setSize()、width()、およびheight()も参照してください 。
[noexcept] QRect QRectF::toAlignedRect() const
この矩形の値に基づいて、この矩形を完全に包含する最小の整数矩形であるQRect を返します。
toRect()も参照してください 。
[noexcept] CGRect QRectF::toCGRect() const
QRectF から CGRect を作成します。
fromCGRect()も参照してください 。
[since 6.5] emscripten::val QRectF::toDOMRect() const
このオブジェクトを DOMRect(https://www.w3.org/TR/geometry-1/)に変換します。
この関数は Qt 6.5 で導入されました。
fromDOMRect()も参照してください 。
[constexpr noexcept] QRect QRectF::toRect() const
この矩形の値に基づいて、QRect を返します。なお、返される矩形の座標は、最も近い整数に丸められます。
QRectF()、toAlignedRect()、およびQRect::toRectF()も参照してください 。
[constexpr noexcept] qreal QRectF::top() const
矩形の上辺の y 座標を返します。y() と同等です。
setTop()、topLeft()、およびtopRight()も参照してください 。
[constexpr noexcept] QPointF QRectF::topLeft() const
矩形の左上隅の位置を返します。
setTopLeft()、top()、およびleft()も参照してください 。
[constexpr noexcept] QPointF QRectF::topRight() const
矩形の右上隅の位置を返します。
setTopRight()、top()、およびright()も参照してください 。
[constexpr noexcept] void QRectF::translate(qreal dx, qreal dy)
現在の位置を基準として、矩形をx軸方向にdx 、y軸方向にdy だけ移動させます。正の値は、矩形を右方向および下方向に移動させます。両方のパラメータは有限値でなければなりません。
moveTopLeft()、moveTo()、およびtranslated()も参照してください 。
[constexpr noexcept] void QRectF::translate(const QPointF &offset)
矩形を、offset 。x() を x 軸方向に、offset 。y() を y 軸方向に、現在の位置を基準として移動させます。
これはオーバーロードされた関数です。
[constexpr noexcept] QRectF QRectF::translated(qreal dx, qreal dy) const
現在の位置を基準として、x 軸方向にdx 、y 軸方向にdy だけ平行移動させた矩形のコピーを返します。正の値は、矩形を右方向および下方向に移動させます。両方のパラメータは有限でなければなりません。
translate()も参照してください 。
[constexpr noexcept] QRectF QRectF::translated(const QPointF &offset) const
現在の位置を基準として、x 軸方向にはoffset.x()、y 軸方向にはoffset.y() の量だけ平行移動させた矩形のコピーを返します。
これはオーバーロードされた関数です。
[constexpr noexcept] QRectF QRectF::transposed() const
幅と高さが入れ替わった矩形のコピーを返します:
QRectF r = {1.5, 5.1, 4.2, 2.4};
r = r.transposed(); // r == {1.5, 5.1, 2.4, 4.2}QSizeF::transposed()も参照してください 。
[noexcept] QRectF QRectF::united(const QRectF &rectangle) const
この矩形と、指定されたrectangle の境界矩形を返します。

intersected()も参照してください 。
[constexpr noexcept] qreal QRectF::width() const
矩形の幅を返します。
setWidth()、height()、およびsize()も参照してください 。
[constexpr noexcept] qreal QRectF::x() const
矩形の左端のx座標を返します。left() と同等です。
setX()、y()、およびtopLeft()も参照してください 。
[constexpr noexcept] qreal QRectF::y() const
矩形の上辺の y 座標を返します。top() と同等です。
setY()、x()、およびtopLeft()も参照してください 。
[noexcept] QRectF QRectF::operator&(const QRectF &rectangle) const
この矩形と指定されたrectangle との共通部分を返します。共通部分がない場合は、空の矩形を返します。
operator&=() およびintersected()も参照してください 。
[noexcept] QRectF &QRectF::operator&=(const QRectF &rectangle)
この長方形と、指定されたrectangle との交点を求めます。
intersected() およびoperator&()も参照してください 。
[constexpr noexcept] QRectF &QRectF::operator+=(const QMarginsF &margins)
margins を矩形に追加し、矩形を拡大します。
marginsAdded()、marginsRemoved()、およびoperator-=()も参照してください 。
[constexpr noexcept] QRectF &QRectF::operator-=(const QMarginsF &margins)
margins によって縮小された矩形を返します。
marginsRemoved()、operator+=()、およびmarginsAdded()も参照してください 。
[noexcept] QRectF QRectF::operator|(const QRectF &rectangle) const
この矩形と指定されたrectangle の境界矩形を返します。
united() およびoperator|=()も参照してください 。
[noexcept] QRectF &QRectF::operator|=(const QRectF &rectangle)
この長方形を、指定されたrectangle と結合します。
関連する非メンバ関数
[constexpr noexcept, since 6.8] bool qFuzzyCompare(const QRectF &lhs, const QRectF &rhs)
矩形 `lhs ` が矩形 `rhs` とほぼ等しい場合は `true ` を返し、そうでない場合は `false` を返します。
この関数は Qt 6.8 で導入されました。
[constexpr noexcept, since 6.8] bool qFuzzyIsNull(const QRectF &rect)
矩形rect の幅と高さの両方がほぼゼロの場合、true を返します。それ以外の場合は、false を返します。
この関数は Qt 6.8 で導入されました。
[constexpr noexcept] bool operator!=(const QRectF &lhs, const QRectF &rhs)
矩形lhs とrhs が十分に異なる場合、true を返し、そうでない場合はfalse を返します。
警告: この関数は厳 密な不等性をチェックしません。代わりに、矩形の座標を比較するためにファジー比較を使用します。
[constexpr noexcept] QRectF operator+(const QRectF &lhs, const QMarginsF &rhs)
`lhs ` の矩形を、`rhs ` のマージン分だけ拡大したものを返します。
[constexpr noexcept] QRectF operator+(const QMarginsF &lhs, const QRectF &rhs)
lhs の矩形を、rhs のマージン分だけ拡大したものを返します。
これはオーバーロードされた関数です。
[constexpr noexcept] QRectF operator-(const QRectF &lhs, const QMarginsF &rhs)
rhs のマージン分だけ縮小されたlhs の矩形を返します。
QDataStream &operator<<(QDataStream &stream, const QRectF &rectangle)
rectangle をstream に書き込み、そのストリームへの参照を返します。
「Qt データ型のシリアライズ」も参照してください 。
[constexpr noexcept] bool operator==(const QRectF &lhs, const QRectF &rhs)
矩形lhs とrhs がほぼ等しい場合はtrue を返し、そうでない場合はfalse を返します。
警告: この関数は厳密な 等価性をチェックするのではなく、ファジー比較を用いて矩形の座標を比較します。
関連項目: qFuzzyCompare 。
QDataStream &operator>>(QDataStream &stream, QRectF &rectangle)
stream からrectangle を読み込み、そのストリームへの参照を返します。
「Qt データ型のシリアライズ」も参照してください 。
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.



