Hi,
I see this method: [stackoverflow.com]
but it doesn’t work.
I substitue QDeclarativeItem by QQuickItem:
void Capturer::save(QQuickItem *item)
{
QPixmap pix(item->width(), item->height());
QPainter painter(&pix);
QStyleOptionGraphicsItem option;
item->paint(&painter, &option, NULL);
pix.save("/path/to/output.png");
}
but QQuickItem hasn’t got an ‘paint’ method.
So, I use the QQuickPaintedItem class:
void Capturer::save(QQuickItem *item)
{
QPixmap pix(item->width(), item->height());
QPainter painter(&pix);
QQuickPaintedItem paintedItem(item);
paintedItem.paint(&painter);
pix.save("/path/to/output.png");
}
but the error is “cannot declare variable ‘paintedItem’ to be of abstract type ‘QQuickPaintedItem’”
How can I to do an capture of my QML element (not the whole scene, but of an sub-element)?
Thanks.
↧