Hi
I have a slot function "displayitem(const QModelIndex& index)" to display the images .
void eBeamTree::displayitem(const QModelIndex& index)
{
QString path
= mod
->filePath
(index
);
dir.setPath(path);
int sizeW = 20;
int sizeH = 20;
for(int i=0;i<listfiles.count();i++)
{
QString filename
= listfiles.
at(i
);
QString filepath
= dir.
absoluteFilePath(filename
);
bool x = tmp.load(filepath);
if(x == true)
{
thumb = (tmp.scaled( 120, 120 ).scaled( sizeW, sizeH, Qt::IgnoreAspectRatio )); //two passes
frame->model->setData(frame->model->index( i, 0 ), thumb, Qt::DecorationRole );
frame->model->setData(frame->model->index(i,1),filename,Qt::DisplayRole);
}
}
frame->treeview->setModel(mod);
frame->treeview->setHeaderHidden(true);
frame->treeview->show();
}
void eBeamTree::displayitem(const QModelIndex& index)
{
QString path = mod->filePath(index);
QDir dir;
dir.setPath(path);
QImage thumb, tmp;
int sizeW = 20;
int sizeH = 20;
QStringList listfiles = dir.entryList(QStringList()<<"*.png",QDir::Files);
for(int i=0;i<listfiles.count();i++)
{
QString filename = listfiles.at(i);
QString filepath = dir.absoluteFilePath(filename);
bool x = tmp.load(filepath);
if(x == true)
{
thumb = (tmp.scaled( 120, 120 ).scaled( sizeW, sizeH, Qt::IgnoreAspectRatio )); //two passes
frame->model->setData(frame->model->index( i, 0 ), thumb, Qt::DecorationRole );
frame->model->setData(frame->model->index(i,1),filename,Qt::DisplayRole);
}
}
frame->treeview->setModel(mod);
frame->treeview->setHeaderHidden(true);
frame->treeview->show();
}
To copy to clipboard, switch view to plain text mode
Declaration of the class eBeamTree and FrameDisplay is provided
{
Q_OBJECT
public:
~eBeamTree();
public:
void populate();
void DockSize();
void FloatSize();
public slots:
void displayitem(const QModelIndex& index);
public:
FrameDisplay* frame;
};
class eBeamTree: public QTreeWidget
{
Q_OBJECT
public:
eBeamTree(QWidget* parent=0);
~eBeamTree();
public:
void populate();
void DockSize();
void FloatSize();
public slots:
void displayitem(const QModelIndex& index);
public:
QDirModel* mod;
QTreeView* view;
QDir eBeamDir;
FrameDisplay* frame;
};
To copy to clipboard, switch view to plain text mode
{
Q_OBJECT
public:
~FrameDisplay();
public:
void DockSize();
void FloatSize();
public:
};
class FrameDisplay: public QListWidget
{
Q_OBJECT
public:
FrameDisplay(QWidget* parent = 0);
~FrameDisplay();
public:
void DockSize();
void FloatSize();
public:
QDirModel *model;
QTreeView* treeview;
};
To copy to clipboard, switch view to plain text mode
I am able to debug the code and check the list of files and filenames , but when running the app, images do not display .
As per the image, the basic idea is when a user clicks any item on the tree (left side)
images under that particular child item should get displayed
Bookmarks