quick fix for layout (#209)

This commit is contained in:
Atul R 2019-11-19 02:30:03 +01:00 committed by GitHub
parent 6dc34d5cae
commit ab9b080fbd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View File

@ -10,7 +10,6 @@
FlexLayout::FlexLayout(QWidget* parentWidget, YGNodeRef parentNode)
: QLayout(parentWidget) {
this->node = parentNode;
this->setSizeConstraint(QLayout::SetFixedSize);
}
FlexLayout::~FlexLayout() {
@ -148,7 +147,14 @@ void FlexLayout::setGeometry(const QRect& rect) {
if (!this->node) {
return;
}
if (this->sizeConstraint() != QLayout::SetFixedSize) {
YGNodeStyleSetHeight(this->node, rect.height());
YGNodeStyleSetWidth(this->node, rect.width());
}
calculateLayout();
QRect calculatedRect = flexutils::getFlexNodeGeometry(this->node);
QLayout::setGeometry(calculatedRect);
uint count = YGNodeGetChildCount(this->node);
@ -159,7 +165,6 @@ void FlexLayout::setGeometry(const QRect& rect) {
QLayoutItem* childItem = ctx->layoutItem();
childItem->setGeometry(childRect);
}
QLayout::setGeometry(rect);
}
void FlexLayout::setFlexNode(YGNodeRef parentNode) { this->node = parentNode; }

View File

@ -41,6 +41,7 @@ label.setInlineStyle(`border: 2px solid green;padding: 10;`);
center.setLayout(new FlexLayout());
center.layout?.addWidget(label);
center.layout?.setProperty('sizeConstraint', 3);
scrollArea.setWidget(center);
win.setCentralWidget(scrollArea);
win.show();