20 #include <QGraphicsWidget>
26 m_currentWidgetIndex(-1)
36 QGraphicsLayout::setGeometry(rect);
38 const QRectF effectiveRect = geometry();
40 for(
int i = 0; i < items.size(); i++) {
41 itemAt(i)->setGeometry(effectiveRect);
50 qreal left, top, right, bottom;
51 getContentsMargins(&left, &top, &right, &bottom);
53 if (m_currentWidgetIndex <= 0 || !
itemAt(m_currentWidgetIndex)) {
57 QSizeF currentWidgetSize =
itemAt(m_currentWidgetIndex)->effectiveSizeHint(which, constraint);
59 return QSizeF( left + right + currentWidgetSize.width(), right + bottom + currentWidgetSize.height());
74 if(!pos && (m_currentWidgetIndex == -1)) {
75 m_currentWidgetIndex = 0;
77 item->graphicsItem()->hide();
80 items.insert(pos, item);
91 items.removeAt(index);
96 QGraphicsItem *currentWidget =
itemAt(m_currentWidgetIndex)->graphicsItem();
97 QGraphicsItem *hiddenWidget =
itemAt(index)->graphicsItem();
99 currentWidget->hide();
100 hiddenWidget->show();
102 m_currentWidgetIndex = index;
107 return m_currentWidgetIndex;