{
if (item != NULL) {
item
->setData
(QImage(item
->data
(MainWindow
::ImagePathRole).
toString()).
scaled(64,
64), Qt
::DecorationRole);
}
}
void MainWindow
::onDirViewActivated(QModelIndex index
) // if this is called again before the thumbnail functions end, it will segfault. {
qDebug() << dirTreeModel->data(index).toString();
QDirIterator i
("/home/michael/Pictures",
QDir::Files);
// fix this to use the selected dir imageListModel->clear();
while (i.hasNext()) {
i.next();
item->setData(i.filePath(), ImagePathRole);
QtConcurrent::run(getThumbnail, item);
imageListModel->appendRow(item);
}
}
void MainWindow::getThumbnail(QStandardItem *item)
{
if (item != NULL) {
item->setData(QImage(item->data(MainWindow::ImagePathRole).toString()).scaled(64, 64), Qt::DecorationRole);
}
}
void MainWindow::onDirViewActivated(QModelIndex index) // if this is called again before the thumbnail functions end, it will segfault.
{
qDebug() << dirTreeModel->data(index).toString();
QDirIterator i("/home/michael/Pictures", QDir::Files); // fix this to use the selected dir
imageListModel->clear();
while (i.hasNext()) {
i.next();
QStandardItem *item = new QStandardItem(i.fileName());
item->setData(i.filePath(), ImagePathRole);
QtConcurrent::run(getThumbnail, item);
imageListModel->appendRow(item);
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks