QGraphicsGridLayout Class

QGraphicsGridLayout 클래스는 그래픽 보기에서 위젯을 관리하기 위한 그리드 레이아웃을 제공합니다. 더 보기...

Header: #include <QGraphicsGridLayout>
CMake: find_package(Qt6 REQUIRED COMPONENTS Widgets)
target_link_libraries(mytarget PRIVATE Qt6::Widgets)
qmake: QT += widgets
상속합니다: QGraphicsLayout

공용 함수

QGraphicsGridLayout(QGraphicsLayoutItem *parent = nullptr)
virtual ~QGraphicsGridLayout()
void addItem(QGraphicsLayoutItem *item, int row, int column, Qt::Alignment alignment = Qt::Alignment())
void addItem(QGraphicsLayoutItem *item, int row, int column, int rowSpan, int columnSpan, Qt::Alignment alignment = Qt::Alignment())
Qt::Alignment alignment(QGraphicsLayoutItem *item) const
Qt::Alignment columnAlignment(int column) const
int columnCount() const
qreal columnMaximumWidth(int column) const
qreal columnMinimumWidth(int column) const
qreal columnPreferredWidth(int column) const
qreal columnSpacing(int column) const
int columnStretchFactor(int column) const
qreal horizontalSpacing() const
QGraphicsLayoutItem *itemAt(int row, int column) const
void removeItem(QGraphicsLayoutItem *item)
Qt::Alignment rowAlignment(int row) const
int rowCount() const
qreal rowMaximumHeight(int row) const
qreal rowMinimumHeight(int row) const
qreal rowPreferredHeight(int row) const
qreal rowSpacing(int row) const
int rowStretchFactor(int row) const
void setAlignment(QGraphicsLayoutItem *item, Qt::Alignment alignment)
void setColumnAlignment(int column, Qt::Alignment alignment)
void setColumnFixedWidth(int column, qreal width)
void setColumnMaximumWidth(int column, qreal width)
void setColumnMinimumWidth(int column, qreal width)
void setColumnPreferredWidth(int column, qreal width)
void setColumnSpacing(int column, qreal spacing)
void setColumnStretchFactor(int column, int stretch)
void setHorizontalSpacing(qreal spacing)
void setRowAlignment(int row, Qt::Alignment alignment)
void setRowFixedHeight(int row, qreal height)
void setRowMaximumHeight(int row, qreal height)
void setRowMinimumHeight(int row, qreal height)
void setRowPreferredHeight(int row, qreal height)
void setRowSpacing(int row, qreal spacing)
void setRowStretchFactor(int row, int stretch)
void setSpacing(qreal spacing)
void setVerticalSpacing(qreal spacing)
qreal verticalSpacing() const

재구현된 공용 함수

virtual int count() const override
virtual void invalidate() override
virtual QGraphicsLayoutItem *itemAt(int index) const override
virtual void removeAt(int index) override
virtual void setGeometry(const QRectF &rect) override
virtual QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const override

상세 설명

가장 일반적인 방법은 힙에 객체를 생성하고 부모 위젯을 생성자에 전달한 다음 addItem()를 호출하여 위젯과 레이아웃을 추가하는 것입니다. QGraphicsGridLayout은 항목을 추가할 때 그리드의 치수를 자동으로 계산합니다.

QGraphicsScene scene;
QGraphicsWidget *textEdit = scene.addWidget(new QTextEdit);
QGraphicsWidget *pushButton = scene.addWidget(new QPushButton);

QGraphicsWidget *form = new QGraphicsWidget;
scene.addItem(form);

QGraphicsGridLayout *layout = new QGraphicsGridLayout(form);
layout->addItem(textEdit, 0, 0);
layout->addItem(pushButton, 0, 1);

또는 레이아웃의 생성자에 부모 위젯을 전달하지 않은 경우 QGraphicsWidget::setLayout()를 호출하여 이 레이아웃을 해당 위젯의 최상위 레이아웃으로 설정하면 위젯이 레이아웃의 소유권을 갖게 됩니다.

레이아웃은 항목에 대한 소유권을 갖습니다. 레이아웃 항목이 QGraphicsItem (예: QGraphicsWidget)에서도 상속되는 경우 레이아웃 항목이 두 개의 소유권 계층에 속하기 때문에 소유권이 모호해질 수 있습니다. 이를 처리하는 방법은 QGraphicsLayoutItem::setOwnedByLayout() 문서를 참조하세요. count () 및 itemAt()을 호출하여 레이아웃의 각 항목에 액세스할 수 있습니다. removeAt ()를 호출하면 레이아웃에서 항목을 파괴하지 않고 제거합니다.

QGraphicsGridLayout의 크기 힌트 및 크기 정책

QGraphicsGridLayout은 각 항목의 크기 힌트와 크기 정책을 존중하며, 그리드의 셀에 항목이 채울 수 있는 공간보다 많은 공간이 있는 경우 각 항목은 해당 항목에 대한 레이아웃의 정렬에 따라 정렬됩니다. setAlignment ()를 호출하여 각 항목의 맞춤을 설정하고 alignment()를 호출하여 모든 항목의 맞춤을 확인할 수 있습니다. setRowAlignment () 및 setColumnAlignment()을 각각 호출하여 전체 행 또는 열에 대한 맞춤을 설정할 수도 있습니다. 기본적으로 항목은 왼쪽 상단에 정렬됩니다.

QGraphicsLinearLayoutQGraphicsWidget참조하세요 .

멤버 함수 문서

QGraphicsGridLayout::QGraphicsGridLayout(QGraphicsLayoutItem *parent = nullptr)

QGraphicsLayout 의 생성자에 parent 을 전달합니다.

[virtual noexcept] QGraphicsGridLayout::~QGraphicsGridLayout()

QGraphicsGridLayout 객체를 삭제합니다.

void QGraphicsGridLayout::addItem(QGraphicsLayoutItem *item, int row, int column, Qt::Alignment alignment = Qt::Alignment())

rowcolumn 의 그리드에 item 를 추가합니다. item 에 대해 선택 사항으로 alignment 을 지정할 수 있습니다.

void QGraphicsGridLayout::addItem(QGraphicsLayoutItem *item, int row, int column, int rowSpan, int columnSpan, Qt::Alignment alignment = Qt::Alignment())

rowcolumn 의 그리드에 item 를 추가합니다. rowSpancolumnSpan 와 선택 사항인 alignment 을 지정할 수 있습니다.

Qt::Alignment QGraphicsGridLayout::alignment(QGraphicsLayoutItem *item) const

item 에 대한 정렬을 반환합니다.

setAlignment()도 참조하세요 .

Qt::Alignment QGraphicsGridLayout::columnAlignment(int column) const

column 에 대한 정렬을 반환합니다.

setColumnAlignment()도 참조하세요 .

int QGraphicsGridLayout::columnCount() const

그리드 레이아웃의 열 수를 반환합니다. 이 값은 레이아웃 항목이 차지하는 마지막 열의 인덱스보다 항상 하나 더 많습니다(빈 열은 끝에 있는 열을 제외하고 계산됩니다).

qreal QGraphicsGridLayout::columnMaximumWidth(int column) const

column 의 최대 너비를 반환합니다.

setColumnMaximumWidth()도 참조하세요 .

qreal QGraphicsGridLayout::columnMinimumWidth(int column) const

column 의 최소 너비를 반환합니다.

setColumnMinimumWidth()도 참조하세요 .

qreal QGraphicsGridLayout::columnPreferredWidth(int column) const

column 에 대한 기본 너비를 반환합니다.

setColumnPreferredWidth()도 참조하세요 .

qreal QGraphicsGridLayout::columnSpacing(int column) const

column 의 열 간격을 반환합니다.

setColumnSpacing()도 참조하세요 .

int QGraphicsGridLayout::columnStretchFactor(int column) const

column 에 대한 스트레치 계수를 반환합니다.

setColumnStretchFactor()도 참조하세요 .

[override virtual] int QGraphicsGridLayout::count() const

재구현합니다: QGraphicsLayout::count() const.

이 그리드 레이아웃의 레이아웃 항목 수를 반환합니다.

qreal QGraphicsGridLayout::horizontalSpacing() const

그리드 레이아웃의 기본 가로 간격을 반환합니다.

setHorizontalSpacing()도 참조하세요 .

[override virtual] void QGraphicsGridLayout::invalidate()

다시 구현합니다: QGraphicsLayout::invalidate().

[override virtual] QGraphicsLayoutItem *QGraphicsGridLayout::itemAt(int index) const

재구현합니다: QGraphicsLayout::itemAt(int i) const.

index, 또는 이 인덱스에 레이아웃 항목이 없는 경우 nullptr 의 레이아웃 항목을 리턴합니다.

QGraphicsLayoutItem *QGraphicsGridLayout::itemAt(int row, int column) const

(row, column)의 레이아웃 항목에 대한 포인터를 반환합니다.

[override virtual] void QGraphicsGridLayout::removeAt(int index)

재구현합니다: QGraphicsLayout::removeAt(int index).

index 에서 레이아웃 항목을 파괴하지 않고 제거합니다. 항목의 소유권은 호출자에게 이전됩니다.

addItem()도 참조하세요 .

void QGraphicsGridLayout::removeItem(QGraphicsLayoutItem *item)

레이아웃 항목 item 을 파괴하지 않고 제거합니다. 항목의 소유권은 호출자에게 이전됩니다.

addItem()도 참조하세요 .

Qt::Alignment QGraphicsGridLayout::rowAlignment(int row) const

row 의 정렬을 반환합니다.

setRowAlignment()도 참조하세요 .

int QGraphicsGridLayout::rowCount() const

그리드 레이아웃의 행 수를 반환합니다. 이 값은 항상 레이아웃 항목이 차지하고 있는 마지막 행의 인덱스보다 하나 더 많습니다(빈 행은 끝에 있는 행을 제외하고 계산됩니다).

qreal QGraphicsGridLayout::rowMaximumHeight(int row) const

행의 최대 높이, row 를 반환합니다.

setRowMaximumHeight()도 참조하세요 .

qreal QGraphicsGridLayout::rowMinimumHeight(int row) const

행의 최소 높이를 반환합니다. row.

setRowMinimumHeight()도 참조하세요 .

qreal QGraphicsGridLayout::rowPreferredHeight(int row) const

행의 기본 설정 높이를 반환합니다. row.

setRowPreferredHeight()도 참조하세요 .

qreal QGraphicsGridLayout::rowSpacing(int row) const

row 의 행 간격을 반환합니다.

setRowSpacing()도 참조하세요 .

int QGraphicsGridLayout::rowStretchFactor(int row) const

row 에 대한 스트레치 계수를 반환합니다.

setRowStretchFactor()도 참조하세요 .

void QGraphicsGridLayout::setAlignment(QGraphicsLayoutItem *item, Qt::Alignment alignment)

item 에 대한 정렬을 alignment 으로 설정합니다.

alignment()도 참조하세요 .

void QGraphicsGridLayout::setColumnAlignment(int column, Qt::Alignment alignment)

column 에 대한 정렬을 alignment 으로 설정합니다.

columnAlignment()도 참조하세요 .

void QGraphicsGridLayout::setColumnFixedWidth(int column, qreal width)

column 의 고정 너비를 width 으로 설정합니다.

void QGraphicsGridLayout::setColumnMaximumWidth(int column, qreal width)

column 의 최대 너비를 width 로 설정합니다.

columnMaximumWidth()도 참조하세요 .

void QGraphicsGridLayout::setColumnMinimumWidth(int column, qreal width)

column 의 최소 너비를 width 로 설정합니다.

columnMinimumWidth()도 참조하세요 .

void QGraphicsGridLayout::setColumnPreferredWidth(int column, qreal width)

column 의 기본 너비를 width 로 설정합니다.

columnPreferredWidth()도 참조하세요 .

void QGraphicsGridLayout::setColumnSpacing(int column, qreal spacing)

column 의 간격을 spacing 으로 설정합니다.

columnSpacing()도 참조하세요 .

void QGraphicsGridLayout::setColumnStretchFactor(int column, int stretch)

column 에 대한 스트레치 계수를 stretch 으로 설정합니다.

columnStretchFactor()도 참조하세요 .

[override virtual] void QGraphicsGridLayout::setGeometry(const QRectF &rect)

재구현합니다: QGraphicsLayoutItem::setGeometry(const QRectF &rect).

그리드 레이아웃의 경계 지오메트리를 rect 로 설정합니다.

void QGraphicsGridLayout::setHorizontalSpacing(qreal spacing)

그리드 레이아웃의 기본 가로 간격을 spacing 으로 설정합니다.

horizontalSpacing()도 참조하세요 .

void QGraphicsGridLayout::setRowAlignment(int row, Qt::Alignment alignment)

row 의 정렬을 alignment 으로 설정합니다.

rowAlignment()도 참조하세요 .

void QGraphicsGridLayout::setRowFixedHeight(int row, qreal height)

행의 고정 높이인 rowheight 으로 설정합니다.

void QGraphicsGridLayout::setRowMaximumHeight(int row, qreal height)

행의 최대 높이인 rowheight 으로 설정합니다.

rowMaximumHeight()도 참조하세요 .

void QGraphicsGridLayout::setRowMinimumHeight(int row, qreal height)

행의 최소 높이인 rowheight 로 설정합니다.

rowMinimumHeight()도 참조하세요 .

void QGraphicsGridLayout::setRowPreferredHeight(int row, qreal height)

행의 기본 높이인 rowheight 으로 설정합니다.

rowPreferredHeight()도 참조하세요 .

void QGraphicsGridLayout::setRowSpacing(int row, qreal spacing)

row 의 간격을 spacing 으로 설정합니다.

rowSpacing()도 참조하세요 .

void QGraphicsGridLayout::setRowStretchFactor(int row, int stretch)

row 의 스트레치 계수를 stretch 로 설정합니다.

rowStretchFactor()도 참조하세요 .

void QGraphicsGridLayout::setSpacing(qreal spacing)

그리드 레이아웃의 기본 간격(세로 및 가로 모두)을 spacing 으로 설정합니다.

rowSpacing() 및 columnSpacing()도 참조하세요 .

void QGraphicsGridLayout::setVerticalSpacing(qreal spacing)

그리드 레이아웃의 기본 세로 간격을 spacing 으로 설정합니다.

verticalSpacing()도 참조하세요 .

[override virtual] QSizeF QGraphicsGridLayout::sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const

재구현합니다: QGraphicsLayoutItem::sizeHint(Qt::SizeHint 어느, const QSizeF &constraint) const.

qreal QGraphicsGridLayout::verticalSpacing() const

그리드 레이아웃의 기본 세로 간격을 반환합니다.

setVerticalSpacing()도 참조하세요 .

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