monitor for declarativeitem resize
This commit is contained in:
parent
c216fe47b8
commit
b958bf1480
@ -39,11 +39,15 @@ public:
|
|||||||
|
|
||||||
void setDeclarativeItem(QDeclarativeItem *item)
|
void setDeclarativeItem(QDeclarativeItem *item)
|
||||||
{
|
{
|
||||||
|
if (m_declarativeItem) {
|
||||||
|
m_declarativeItem.data()->removeSceneEventFilter(this);
|
||||||
|
}
|
||||||
m_declarativeItem = item;
|
m_declarativeItem = item;
|
||||||
static_cast<QGraphicsItem *>(item)->setParentItem(this);
|
static_cast<QGraphicsItem *>(item)->setParentItem(this);
|
||||||
setMinimumWidth(item->implicitWidth());
|
setMinimumWidth(item->implicitWidth());
|
||||||
setMinimumHeight(item->implicitHeight());
|
setMinimumHeight(item->implicitHeight());
|
||||||
resize(item->width(), item->height());
|
resize(item->width(), item->height());
|
||||||
|
item->installSceneEventFilter(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
QDeclarativeItem *declarativeItem() const
|
QDeclarativeItem *declarativeItem() const
|
||||||
@ -60,6 +64,15 @@ protected:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool sceneEventFilter(QGraphicsItem *watched, QEvent *event)
|
||||||
|
{
|
||||||
|
if (event->type() == QEvent::GraphicsSceneResize) {
|
||||||
|
resize(watched->boundingRect().size());
|
||||||
|
}
|
||||||
|
|
||||||
|
return QGraphicsWidget::sceneEventFilter(watched, event);
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QWeakPointer<QDeclarativeItem> m_declarativeItem;
|
QWeakPointer<QDeclarativeItem> m_declarativeItem;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user