{
if (role == ImageRole) {
return QString::number(index.
row());
}
/// other data
}
{
int row = id.toInt();
// load BLOB for image on row "row", return
}
QVariant MyModel::data(const QModelIndex & index, int role) const
{
if (role == ImageRole) {
return QString::number(index.row());
}
/// other data
}
QImage MyModel::image(const QString &id) const
{
int row = id.toInt();
// load BLOB for image on row "row", return
}
To copy to clipboard, switch view to plain text mode
Image {
source: "image://mysqlimageprovider/" * model.image
}
Image {
source: "image://mysqlimageprovider/" * model.image
}
To copy to clipboard, switch view to plain text mode
QImage MyImageProvider
::requestImage(const QString &d,
QSize *size,
const QSize &requestedSize,
bool requestedAutoTransform
) {
QImage image
= myModel
->image
(id
);
*size = image.size();
return image;
}
QImage MyImageProvider::requestImage(const QString &d, QSize *size, const QSize &requestedSize, bool requestedAutoTransform)
{
QImage image = myModel->image(id);
*size = image.size();
return image;
}
To copy to clipboard, switch view to plain text mode
You could even inherit your model from both the current base class and QQuickImageProvider.
Cheers,
_
Bookmarks