Fix Item::suggestedRect() when the parentContainer() wasn't root

This commit is contained in:
Sergio Martins
2020-05-13 21:10:15 +01:00
parent be1a2a3878
commit b743565ea3
2 changed files with 28 additions and 3 deletions

View File

@@ -1189,9 +1189,16 @@ QRect ItemContainer::suggestedDropRect(QSize minSize, const Item *relativeTo, Lo
const int count = sizes.count();
if (relativeTo && count == 1) {
// If it's the only item then the result is that it's relative to the whole layout
// So simplify our code
relativeTo = nullptr;
// When the container only has one item we can do some simplifications
if (isRoot()) {
// Means the result is relative to the whole window
relativeTo = nullptr;
} else {
// Do it relative to this container instead
return parentContainer()->suggestedDropRect(minSize, this, loc);
}
}
if (relativeTo) {