Originally Posted by
wysota
In QtQuick 1 all items are derived from
QGraphicsItem so you can override the paint() method for them. It should be quite straightforward to implement a custom image item, e.g. using
QGraphicsEffect.
Ok, this is whati I've done so far:
{
int h = m_explicitSourceSize ? m_sourcesize.height() : image.height();
int w = m_explicitSourceSize ? m_sourcesize.width() : image.width();
pen.setColor(Qt::darkGray);
pen.setJoinStyle(Qt::RoundJoin);
painter->setBrush(brush);
painter->setPen(pen);
painter->drawRoundedRect(0, 0, w, h, w/2, h/2);
}
void RoundImage::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
{
QImage image(m_url.url());
QBrush brush(image);
int h = m_explicitSourceSize ? m_sourcesize.height() : image.height();
int w = m_explicitSourceSize ? m_sourcesize.width() : image.width();
QPen pen;
pen.setColor(Qt::darkGray);
pen.setJoinStyle(Qt::RoundJoin);
painter->setBrush(brush);
painter->setPen(pen);
painter->drawRoundedRect(0, 0, w, h, w/2, h/2);
}
To copy to clipboard, switch view to plain text mode
and the m_url is a QUrl.
The problem is that I don't know how to load an image or pixmap from an url and I need to use a QUrl because the source can be an image provider too
Bookmarks