I know this is an old question, but here is another option.
I had a similar problem with images in QToolTip. I could reference the images from the disk perfectly, but the default zoom behavior is nonsmooth and looked awful. I overridden my own tooltip class and used a custom class QTextDocumentso that I could override QTextDocument::loadResource().
In your case, you can specify the keyword in the imgsrc attribute . Then in your implementation loadResource()return the QPixmap identified with the keyword.
Here is the base code (untested in this context):
class MyTextDocument : public QTextDocument
{
protected:
virtual QVariant loadResource(int type, const QUrl &name)
{
QString t = name.toString();
if (t == myKeyword)
return myPixmap;
return QTextDocument::loadResource(type, name);
}
};
class MyLabel : public QFrame
{
public:
MyLabel(QWidget *parent)
: QFrame(parent)
, m_doc(new MyTextDocument(this))
{ }
virtual void paintEvent(QPaintEvent *e)
{
QStylePainter p(this);
m_doc->drawContents(&p);
}
};