monitor for declarativeitem resize
This commit is contained in:
parent
c216fe47b8
commit
b958bf1480
@ -39,11 +39,15 @@ public:
|
||||
|
||||
void setDeclarativeItem(QDeclarativeItem *item)
|
||||
{
|
||||
if (m_declarativeItem) {
|
||||
m_declarativeItem.data()->removeSceneEventFilter(this);
|
||||
}
|
||||
m_declarativeItem = item;
|
||||
static_cast<QGraphicsItem *>(item)->setParentItem(this);
|
||||
setMinimumWidth(item->implicitWidth());
|
||||
setMinimumHeight(item->implicitHeight());
|
||||
resize(item->width(), item->height());
|
||||
item->installSceneEventFilter(this);
|
||||
}
|
||||
|
||||
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:
|
||||
QWeakPointer<QDeclarativeItem> m_declarativeItem;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user