QSize Class

QSize 클래스는 정수점 정밀도를 사용하여 2차원 개체의 크기를 정의합니다. 더 보기...

Header: #include <QSize>
CMake: find_package(Qt6 REQUIRED COMPONENTS Core)
target_link_libraries(mytarget PRIVATE Qt6::Core)
qmake: QT += core

공용 함수

QSize()
QSize(int width, int height)
QSize boundedTo(const QSize &otherSize) const
QSize expandedTo(const QSize &otherSize) const
QSize grownBy(QMargins margins) const
int height() const
bool isEmpty() const
bool isNull() const
bool isValid() const
int &rheight()
int &rwidth()
void scale(int width, int height, Qt::AspectRatioMode mode)
void scale(const QSize &size, Qt::AspectRatioMode mode)
QSize scaled(int width, int height, Qt::AspectRatioMode mode) const
QSize scaled(const QSize &s, Qt::AspectRatioMode mode) const
void setHeight(int height)
void setWidth(int width)
QSize shrunkBy(QMargins margins) const
CGSize toCGSize() const
(since 6.4) QSizeF toSizeF() const
void transpose()
QSize transposed() const
int width() const
QSize &operator*=(qreal factor)
QSize &operator+=(const QSize &size)
QSize &operator-=(const QSize &size)
QSize &operator/=(qreal divisor)
bool operator!=(const QSize &lhs, const QSize &rhs)
QSize operator*(const QSize &size, qreal factor)
QSize operator*(qreal factor, const QSize &size)
QSize operator+(const QSize &s1, const QSize &s2)
QSize operator-(const QSize &s1, const QSize &s2)
QSize operator/(const QSize &size, qreal divisor)
QDataStream &operator<<(QDataStream &stream, const QSize &size)
bool operator==(const QSize &lhs, const QSize &rhs)
QDataStream &operator>>(QDataStream &stream, QSize &size)

자세한 설명

크기는 width() 및 height()로 지정됩니다. 생성자에서 설정하고 setWidth(), setHeight() 또는 scale() 함수를 사용하거나 산술 연산자를 사용하여 변경할 수 있습니다. rwidth () 및 rheight() 함수를 사용하여 너비와 높이에 대한 참조를 검색하여 크기를 직접 조작할 수도 있습니다. 마지막으로 transpose() 함수를 사용하여 너비와 높이를 바꿀 수 있습니다.

isValid() 함수는 크기가 유효한지 여부를 결정합니다(유효한 크기는 너비와 높이가 모두 0보다 크거나 같음). isEmpty () 함수는 너비와 높이 중 하나라도 0보다 작거나 같으면 true 을 반환하고, isNull() 함수는 너비와 높이가 모두 0인 경우에만 true 을 반환합니다.

expandedTo() 함수를 사용하여 크기와 주어진 크기의 최대 높이와 너비를 가진 크기를 검색합니다. 마찬가지로 boundedTo() 함수는 크기와 주어진 크기의 최소 높이와 너비를 포함하는 크기를 반환합니다.

QSize 객체는 비교뿐만 아니라 스트리밍도 가능합니다.

QSizeF, QPoint, QRect참조하세요 .

멤버 함수 문서

[constexpr noexcept] QSize QSize::grownBy(QMargins margins) const

이 크기를 늘린 결과 크기를 반환합니다 margins.

shrunkBy()도 참조하세요 .

[constexpr noexcept] QSize QSize::shrunkBy(QMargins margins) const

이 크기를 margins 만큼 줄인 크기를 반환합니다.

grownBy()도 참조하세요 .

[constexpr noexcept] QSize::QSize()

폭과 높이가 잘못된 크기를 생성합니다(예: isValid()는 false)를 반환합니다).

isValid()도 참조하십시오 .

[constexpr noexcept] QSize::QSize(int width, int height)

주어진 widthheight 으로 크기를 구성합니다.

setWidth() 및 setHeight()도 참조하세요 .

[constexpr noexcept] QSize QSize::boundedTo(const QSize &otherSize) const

이 크기와 주어진 otherSize 의 최소 너비와 높이를 가진 크기를 반환합니다.

expandedTo() 및 scale()도 참조하세요 .

[constexpr noexcept] QSize QSize::expandedTo(const QSize &otherSize) const

이 크기와 주어진 otherSize 의 최대 너비와 높이를 가진 크기를 반환합니다.

boundedTo() 및 scale()도 참조하세요 .

[constexpr noexcept] int QSize::height() const

높이를 반환합니다.

width() 및 setHeight()도 참조하세요 .

[constexpr noexcept] bool QSize::isEmpty() const

너비와 높이 중 하나라도 0보다 작거나 같으면 true 을 반환하고, 그렇지 않으면 false 을 반환합니다.

isNull() 및 isValid()도 참조하세요 .

[constexpr noexcept] bool QSize::isNull() const

너비와 높이가 모두 0이면 true 을 반환하고, 그렇지 않으면 false를 반환합니다.

isValid() 및 isEmpty()도 참조하세요 .

[constexpr noexcept] bool QSize::isValid() const

너비와 높이가 모두 0보다 크면 true 을 반환하고, 그렇지 않으면 false 을 반환합니다.

isNull() 및 isEmpty()도 참조하세요 .

[constexpr noexcept] int &QSize::rheight()

높이에 대한 참조를 반환합니다.

참조를 사용하면 높이를 직접 조작할 수 있습니다. 예를 들어

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

// size becomes (100,15)

rwidth() 및 setHeight()도 참조하세요 .

[constexpr noexcept] int &QSize::rwidth()

너비에 대한 참조를 반환합니다.

참조를 사용하면 너비를 직접 조작할 수 있습니다. 예를 들어

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

// size becomes (120,10)

rheight() 및 setWidth()도 참조하세요 .

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

지정된 mode 에 따라 지정된 widthheight 을 사용하여 직사각형으로 크기를 조정합니다:

  • modeQt::IgnoreAspectRatio 인 경우 크기는 (width, height)로 설정됩니다.
  • modeQt::KeepAspectRatio 인 경우 현재 크기는 가로 세로 비율을 유지하면서 (width, height) 내부의 가능한 한 큰 직사각형으로 조정됩니다.
  • modeQt::KeepAspectRatioByExpanding 인 경우 현재 크기는 가로 세로 비율을 유지하면서 외부 (width, height)에서 가능한 한 작은 직사각형으로 조정됩니다.

예시:

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)

setWidth(), setHeight() 및 scaled()도 참조하세요 .

[noexcept] void QSize::scale(const QSize &size, Qt::AspectRatioMode mode)

이 함수는 오버로드된 함수입니다.

지정된 mode 에 따라 지정된 size 의 직사각형으로 크기를 조정합니다.

[noexcept] QSize QSize::scaled(int width, int height, Qt::AspectRatioMode mode) const

지정된 mode 에 따라 지정된 widthheight 을 사용하여 직사각형으로 스케일링된 크기를 반환합니다.

scale()도 참조하세요 .

[noexcept] QSize QSize::scaled(const QSize &s, Qt::AspectRatioMode mode) const

이 함수는 오버로드된 함수입니다.

지정된 mode 에 따라 지정된 크기의 직사각형으로 스케일링된 크기 s 를 반환합니다.

[constexpr noexcept] void QSize::setHeight(int height)

주어진 height 으로 높이를 설정합니다.

rheight(), height(), setWidth()도 참조하세요 .

[constexpr noexcept] void QSize::setWidth(int width)

너비를 지정된 width 로 설정합니다.

rwidth(), width(), setHeight()도 참조하세요 .

[noexcept] CGSize QSize::toCGSize() const

QSize 에서 CGSize를 생성합니다.

QSizeF::fromCGSize()도 참조하세요 .

[constexpr noexcept, since 6.4] QSizeF QSize::toSizeF() const

이 크기를 부동소수점 정확도를 가진 크기로 반환합니다.

이 함수는 Qt 6.4에 도입되었습니다.

QSizeF::toSize()도 참조하십시오 .

[noexcept] void QSize::transpose()

너비와 높이 값을 바꿉니다.

setWidth(), setHeight() 및 transposed()도 참조하세요 .

[constexpr noexcept] QSize QSize::transposed() const

너비와 높이가 바뀐 QSize 를 반환합니다.

transpose()도 참조하세요 .

[constexpr noexcept] int QSize::width() const

너비를 반환합니다.

height() 및 setWidth()도 참조하세요 .

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

이 함수는 오버로드된 함수입니다.

너비와 높이에 주어진 factor 을 곱하고 크기에 대한 참조를 반환합니다.

결과는 가장 가까운 정수로 반올림됩니다.

scale()도 참조하세요 .

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

주어진 size 크기에 추가하고 이 크기에 대한 참조를 반환합니다. 예를 들어

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

// s becomes (2,11)

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

크기에서 주어진 size 을 빼고 이 크기에 대한 참조를 반환합니다. 예를 들어

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

// s becomes (4,3)

QSize &QSize::operator/=(qreal divisor)

이 함수는 오버로드된 함수입니다.

너비와 높이를 모두 주어진 divisor 으로 나누고 크기에 대한 참조를 반환합니다.

결과는 가장 가까운 정수로 반올림됩니다.

QSize::scale()도 참조하세요 .

관련 비회원

[constexpr noexcept] bool operator!=(const QSize &lhs, const QSize &rhs)

lhsrhs 이 다르면 true 을 반환하고, 그렇지 않으면 false 을 반환합니다.

[constexpr noexcept] QSize operator*(const QSize &size, qreal factor)

주어진 size 에 주어진 factor 을 곱한 후 가장 가까운 정수로 반올림한 결과를 반환합니다.

QSize::scale()도 참조하세요 .

[constexpr noexcept] QSize operator*(qreal factor, const QSize &size)

이 함수는 오버로드된 함수입니다.

주어진 size 에 주어진 factor 을 곱한 후 가장 가까운 정수로 반올림한 결과를 반환합니다.

[constexpr noexcept] QSize operator+(const QSize &s1, const QSize &s2)

s1s2 의 합계를 반환하며, 각 구성 요소는 개별적으로 추가됩니다.

[constexpr noexcept] QSize operator-(const QSize &s1, const QSize &s2)

s1 에서 s2 을 뺀 값을 반환하며, 각 구성 요소는 개별적으로 뺍니다.

QSize operator/(const QSize &size, qreal divisor)

이 함수는 오버로드된 함수입니다.

주어진 size 을 주어진 divisor 으로 나눈 후 가장 가까운 정수로 반올림한 결과를 반환합니다.

QSize::scale()도 참조하세요 .

QDataStream &operator<<(QDataStream &stream, const QSize &size)

주어진 size 을 주어진 stream 에 쓰고 스트림에 대한 참조를 반환합니다.

Qt 데이터 유형 직렬화도참조하십시오 .

[constexpr noexcept] bool operator==(const QSize &lhs, const QSize &rhs)

lhsrhs 이 같으면 true 을 반환하고, 그렇지 않으면 false 을 반환합니다.

QDataStream &operator>>(QDataStream &stream, QSize &size)

주어진 stream 에서 주어진 size 으로 크기를 읽고 스트림에 대한 참조를 반환합니다.

Qt 데이터 유형 직렬화도참조하십시오 .

© 2025 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.