create the delegate in the proper context

This commit is contained in:
Marco Martin 2012-08-27 19:19:22 +02:00
parent c36c2f88aa
commit 523314b4a9

View File

@ -30,6 +30,7 @@
#include <QApplication>
#include <QGraphicsScene>
#include <QGraphicsView>
#include <QDeclarativeContext>
/*!
A DragArea is used to make an item draggable.
@ -207,7 +208,7 @@ void DeclarativeDragArea::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
drag->setPixmap(QPixmap::fromImage(m_delegateImage));
} else if (m_delegate) {
// Render the delegate to a Pixmap
QDeclarativeItem* item = qobject_cast<QDeclarativeItem *>(m_delegate->create());
QDeclarativeItem* item = qobject_cast<QDeclarativeItem *>(m_delegate->create(m_delegate->creationContext()));
QGraphicsScene scene;
scene.addItem(item);
@ -217,6 +218,7 @@ void DeclarativeDragArea::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
QPainter painter(&pixmap);
painter.setRenderHint(QPainter::Antialiasing);
painter.setRenderHint(QPainter::SmoothPixmapTransform);
scene.render(&painter);
painter.end();
delete item;