fix parent is scroller error

This commit is contained in:
王劲鹏 2021-04-25 14:36:42 +08:00 committed by osborn
parent 644f58e221
commit 3655513be3

View File

@ -132,6 +132,11 @@ void DoricLayouts::measureSelf(QSizeF targetSize) {
qreal width; qreal width;
if (this->widthSpec == DoricLayoutSpec::DoricLayoutMost) { if (this->widthSpec == DoricLayoutSpec::DoricLayoutMost) {
QQuickItem *parent = this->view->parentItem(); QQuickItem *parent = this->view->parentItem();
if (parent == nullptr) {
// incase parent is scroller
width = targetSize.width();
setMeasuredWidth(targetSize.width());
} else {
DoricLayouts *parentDoricLayout = DoricLayouts *parentDoricLayout =
(DoricLayouts *)(parent->property("doricLayout").toULongLong()); (DoricLayouts *)(parent->property("doricLayout").toULongLong());
if (parentDoricLayout != nullptr && if (parentDoricLayout != nullptr &&
@ -143,6 +148,7 @@ void DoricLayouts::measureSelf(QSizeF targetSize) {
width = targetSize.width(); width = targetSize.width();
setMeasuredWidth(targetSize.width()); setMeasuredWidth(targetSize.width());
} }
}
} else if (this->widthSpec == DoricLayoutSpec::DoricLayoutJust) { } else if (this->widthSpec == DoricLayoutSpec::DoricLayoutJust) {
width = this->width; width = this->width;
setMeasuredWidth(this->width); setMeasuredWidth(this->width);
@ -154,6 +160,11 @@ void DoricLayouts::measureSelf(QSizeF targetSize) {
qreal height; qreal height;
if (this->heightSpec == DoricLayoutSpec::DoricLayoutMost) { if (this->heightSpec == DoricLayoutSpec::DoricLayoutMost) {
QQuickItem *parent = this->view->parentItem(); QQuickItem *parent = this->view->parentItem();
if (parent == nullptr) {
// incase parent is scroller
height = targetSize.height();
setMeasuredHeight(targetSize.height());
} else {
DoricLayouts *parentDoricLayout = DoricLayouts *parentDoricLayout =
(DoricLayouts *)(parent->property("doricLayout").toULongLong()); (DoricLayouts *)(parent->property("doricLayout").toULongLong());
if (parentDoricLayout != nullptr && if (parentDoricLayout != nullptr &&
@ -165,6 +176,8 @@ void DoricLayouts::measureSelf(QSizeF targetSize) {
height = targetSize.height(); height = targetSize.height();
setMeasuredHeight(targetSize.height()); setMeasuredHeight(targetSize.height());
} }
}
} else if (this->heightSpec == DoricLayoutSpec::DoricLayoutJust) { } else if (this->heightSpec == DoricLayoutSpec::DoricLayoutJust) {
height = this->height; height = this->height;
setMeasuredHeight(this->height); setMeasuredHeight(this->height);