The first element corresponds to the lower left corner of the texture image. Subsequent elements progress left-to-right through the remaining texels in the lowest row of the texture image, and then in successively higher rows of the texture image. The final element corresponds to the upper right corner of the texture image.
int w = r.width() - (m_items.count() - 1) * spacing(); int h = r.height() - (m_items.count() - 1) * spacing(); int i = 0; while (i < m_items.size()) { QLayoutItem *o = m_items.at(i); QRect geom(r.x() + i * spacing(), r.y() + i * spacing(), w, h); o->setGeometry(geom); ++i; } }
QSize OverlapLayout::sizeHint() const { QSize s(0, 0); for (auto e : things) { s = s.expandedTo(e->sizeHint()); }
return s; }
QSize OverlapLayout::minimumSize() const { QSize s(0, 0); for (auto e : things) { s = s.expandedTo(e->minimumSize()); }
return s; }
int OverlapLayout::count() const { int num = 0; for (auto e : things) { num += e->count(); }
return num; }
QLayoutItem* OverlapLayout::itemAt(int index) const { int num = 0; int next = 0; for (auto e : things) { next = num + e->count(); if (index < next) { return e->itemAt(index - num); } num = next; }
int num = 0; int next = 0; for (auto e : things) { next = num + e->count(); if (index < next) { e->invalidate(); return e->takeAt(index - num); } num = next; }
return nullptr; }
void OverlapLayout::setGeometry(const QRect& r) { if (things.size() == 0) return;
for (auto e : things) { e->invalidate(); e->setGeometry(r); } }