[Qt-qml] QML Component Snapshot / Cover-Flow (PathView) implementation suggestions
Gregory Schlomoff
gregory.schlomoff at gmail.com
Thu Nov 18 05:30:42 CET 2010
> There's no built-in QML-based way to take snapshots -- you'd need a custom
> C++ component to do something like this (it does seem to be a frequent
> request; has anyone else made a component for this already?).
Yes, we did that in our custom drag&drop component.
Here's the relevant snippet from
http://bitbucket.org/gregschlom/qml-drag-drop/src/e5dbe26c3073/DeclarativeDragArea.cpp
==========
QDeclarativeItem* item // This is the item whose snapshot you want to take
QGraphicsScene scene;
scene.addItem(item);
QPixmap pixmap(scene.sceneRect().width(), scene.sceneRect().height());
pixmap.fill(Qt::transparent);
QPainter painter(&pixmap);
painter.setRenderHint(QPainter::Antialiasing);
scene.render(&painter);
// And now, enjoy your pixmap with the freshly painted item
=========
Cheers,
greg
More information about the Qt-qml
mailing list