QLayoutItem Class

QLayoutItem 클래스는 QLayout 가 조작하는 추상 항목을 제공합니다. 더 보기...

헤더: #include <QLayoutItem>
CMake: find_package(Qt6 REQUIRED COMPONENTS Widgets)
target_link_libraries(mytarget PRIVATE Qt6::Widgets)
qmake: QT += widgets
에 의해 상속되었습니다:

QLayout, QSpacerItem, 그리고 QWidgetItem

공용 함수

QLayoutItem(Qt::Alignment alignment = Qt::Alignment())
virtual ~QLayoutItem()
Qt::Alignment alignment() const
virtual QSizePolicy::ControlTypes controlTypes() const
virtual Qt::Orientations expandingDirections() const = 0
virtual QRect geometry() const = 0
virtual bool hasHeightForWidth() const
virtual int heightForWidth(int) const
virtual void invalidate()
virtual bool isEmpty() const = 0
virtual QLayout *layout()
virtual QSize maximumSize() const = 0
virtual int minimumHeightForWidth(int w) const
virtual QSize minimumSize() const = 0
void setAlignment(Qt::Alignment alignment)
virtual void setGeometry(const QRect &r) = 0
virtual QSize sizeHint() const = 0
virtual QSpacerItem *spacerItem()
virtual QWidget *widget() const

상세 설명

사용자 정의 레이아웃에서 사용됩니다.

sizeHint(), minimumSize(), maximumSize() 및 expandingDirections() 등 레이아웃에 대한 정보를 반환하는 순수 가상 함수가 제공됩니다.

레이아웃의 지오메트리는 setGeometry() 및 geometry(), 정렬은 setAlignment() 및 alignment()로 설정 및 검색할 수 있습니다.

isEmpty()는 레이아웃 항목이 비어 있는지 여부를 반환합니다. 구체적인 항목이 QWidget 인 경우 widget()를 사용하여 검색할 수 있습니다. layout () 및 spacerItem()도 마찬가지입니다.

일부 레이아웃에는 너비와 높이 상호 의존성이 있습니다. 이는 hasHeightForWidth(), heightForWidth() 및 minimumHeightForWidth()를 사용하여 표현할 수 있습니다. 자세한 설명은 Qt 분기별 문서 너비와 높이 교환을 참조하십시오.

QLayout참조하세요 .

멤버 함수 문서

[explicit] QLayoutItem::QLayoutItem(Qt::Alignment alignment = Qt::Alignment())

alignment 로 레이아웃 항목을 구성합니다. 모든 하위 클래스가 정렬을 지원하는 것은 아닙니다.

[virtual noexcept] QLayoutItem::~QLayoutItem()

QLayoutItem 를 파괴합니다.

Qt::Alignment QLayoutItem::alignment() const

이 항목의 정렬을 반환합니다.

setAlignment()도 참조하세요 .

[virtual] QSizePolicy::ControlTypes QLayoutItem::controlTypes() const

레이아웃 항목의 컨트롤 유형을 반환합니다. QWidgetItem 의 경우 컨트롤 유형은 위젯의 크기 정책에서 가져오며, QLayoutItem 의 경우 레이아웃의 콘텐츠에서 파생된 컨트롤 유형입니다.

QSizePolicy::controlType()도 참조하세요 .

[pure virtual] Qt::Orientations QLayoutItem::expandingDirections() const

이 레이아웃 항목이 sizeHint()보다 더 많은 공간을 사용할 수 있는지 여부를 반환합니다. Qt::Vertical 또는 Qt::Horizontal 값은 한 차원만 늘리겠다는 의미이고 Qt::Vertical | Qt::Horizontal 값은 두 차원 모두 늘리겠다는 의미입니다.

[pure virtual] QRect QLayoutItem::geometry() const

이 레이아웃 항목에 포함된 사각형을 반환합니다.

setGeometry()도 참조하세요 .

[virtual] bool QLayoutItem::hasHeightForWidth() const

이 레이아웃의 기본 높이가 너비에 따라 달라지는 경우 true 를 반환하고, 그렇지 않으면 false 을 반환합니다. 기본 구현은 false를 반환합니다.

너비에 대한 높이를 지원하는 레이아웃 관리자에서 이 함수를 다시 구현하세요.

heightForWidth() 및 QWidget::heightForWidth()도 참조하세요 .

[virtual] int QLayoutItem::heightForWidth(int) const

이 기본 구현에서는 사용되지 않는 너비가 주어질 때 이 레이아웃 항목에 대해 기본 설정된 높이를 반환합니다.

기본 구현은 -1을 반환하며, 이는 기본 높이가 항목의 너비와 무관하다는 것을 나타냅니다. hasHeightForWidth () 함수를 사용하는 것이 일반적으로 이 함수를 호출하고 -1을 테스트하는 것보다 훨씬 빠릅니다.

너비에 대한 높이를 지원하는 레이아웃 관리자에서 이 함수를 다시 구현하세요. 일반적인 구현은 다음과 같습니다:

int MyLayout::heightForWidth(int w) const
{
    if (cache_dirty || cached_width != w) {
        MyLayout *that = const_cast<MyLayout *>(this);
        int h = calculateHeightForWidth(w);
        that->cached_hfw = h;
        return h;
    }
    return cached_hfw;
}

캐싱이 없으면 레이아웃에 기하급수적인 시간이 소요되므로 캐싱을 강력히 권장합니다.

hasHeightForWidth()도 참조하세요 .

[virtual] void QLayoutItem::invalidate()

이 레이아웃 항목의 캐시된 정보를 모두 무효화합니다.

[pure virtual] bool QLayoutItem::isEmpty() const

이 항목이 비어 있는지, 즉 위젯이 포함되어 있는지 여부를 반환하기 위해 서브클래스에 구현됩니다.

[virtual] QLayout *QLayoutItem::layout()

이 항목이 QLayout 인 경우 QLayout 으로 반환되고, 그렇지 않으면 nullptr 이 반환됩니다. 이 함수는 타입 안전 캐스팅을 제공합니다.

spacerItem() 및 widget()도 참조하세요 .

[pure virtual] QSize QLayoutItem::maximumSize() const

이 항목의 최대 크기를 반환하기 위해 서브클래스에 구현됩니다.

[virtual] int QLayoutItem::minimumHeightForWidth(int w) const

주어진 너비에 대해 이 위젯에 필요한 최소 높이( w)를 반환합니다. 기본 구현은 heightForWidth(w)를 반환합니다.

[pure virtual] QSize QLayoutItem::minimumSize() const

이 항목의 최소 크기를 반환하기 위해 서브클래스에 구현됩니다.

void QLayoutItem::setAlignment(Qt::Alignment alignment)

이 항목의 맞춤을 alignment 로 설정합니다.

참고: 항목 정렬은 시각적 효과가 있는 QLayoutItem 서브 클래스에서만 지원됩니다. 레이아웃을 위한 빈 공간을 제공하는 QSpacerItem 을 제외하고 QLayoutItem 을 상속하는 모든 공용 Qt 클래스는 항목 정렬을 지원합니다.

alignment()도 참조하십시오 .

[pure virtual] void QLayoutItem::setGeometry(const QRect &r)

이 항목의 지오메트리를 r 로 설정하기 위해 하위 클래스에서 구현되었습니다.

geometry()도 참조하세요 .

[pure virtual] QSize QLayoutItem::sizeHint() const

이 항목의 기본 크기를 반환하기 위해 하위 클래스에서 구현됩니다.

[virtual] QSpacerItem *QLayoutItem::spacerItem()

이 항목이 QSpacerItem 인 경우 QSpacerItem 으로 반환되고, 그렇지 않으면 nullptr 이 반환됩니다. 이 함수는 타입 안전 캐스팅을 제공합니다.

layout() 및 widget()도 참조하세요 .

[virtual] QWidget *QLayoutItem::widget() const

이 항목이 QWidget 를 관리하는 경우 해당 위젯을 반환합니다. 그렇지 않으면 nullptr 이 반환됩니다.

참고: layout() 및 spacerItem() 함수는 형변환을 수행하지만 이 함수는 다른 객체를 반환합니다. QLayoutQSpacerItemQLayoutItem 을 상속하지만 QWidget 은 상속하지 않습니다.

layout() 및 spacerItem()도 참조하세요 .

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