How assign dynamically QPixmap to QML delegate when using QAbstractItemModel in 5.7 ?
I do have
Code:
TreeView {
id: view
enabled: !settingsData.allDisabled
TableViewColumn {
title: "Icon"
role: "image"
width: 32
delegate: Image {
height: 20
source: "image://icons/" + id
// source: image
}
}
TableViewColumn {
title: "Name"
role: "display"
resizable: true
visible: true
}
TableViewColumn {
And
Code:
QHash<int, QByteArray> PasswordListModel::roleNames() const {
result.insert(ImageRole, QByteArrayLiteral("image"));
result.insert(LastAccessedRole, QByteArrayLiteral("lastAccessed"));
result.insert(LastModifiedRole, QByteArrayLiteral("lastModified"));
result.insert(ContainerIdRole, QByteArrayLiteral("containerId"));
return result;
}
and
Code:
{
if (!index.isValid())
.
.
.
case ImageRole: {
qDebug () << "ImageRole";
// return QVariant(QString("image://icons/password_icon"));
// return QVariant(QString("password_icon"));
}
How to ImagaProvider will get notification to return correct bitmap for QML side. Based on my debugging, MyClass::requestPixmap(const QString &id, QSize */*size*/, const QSize &requestedSize) will not get request from system.
Re: How assign dynamically QPixmap to QML delegate when using QAbstractItemModel in 5
Maybe you can start by describing what you have.
I assume you images are not on disk or anywhere else that is referencable by URL, right?
How does your application generate them and where/how to you store them in memory?
Cheers,
_
Re: How assign dynamically QPixmap to QML delegate when using QAbstractItemModel in 5
It's in the disk, QQuickImageProvider derived class will provided them . Model should show correct icon based on type of item which be different in child list. Icons are included in the project.
Re: How assign dynamically QPixmap to QML delegate when using QAbstractItemModel in 5
Ok, but if they are on disk, why do you need a custom image provider?
Just let the model return the file URI. see QUrl::fromLocalFile().
Cheers,
_
Re: How assign dynamically QPixmap to QML delegate when using QAbstractItemModel in 5
yes, ok. How to assign this URI to delegate in use ?
Re: How assign dynamically QPixmap to QML delegate when using QAbstractItemModel in 5
Like any other model data
Code:
source: styleData.value
Cheers,
_
Re: How assign dynamically QPixmap to QML delegate when using QAbstractItemModel in 5