how use QFileSystemModel with QListView ?
Hi friends,
i use Qt jambi with eclipse and i have a small problem with QFileSystemModel ..... this model doesn't show me what i want exactly
i just want to know how QFileSystemModel work to obtain this result
went i select a folder in left side ( QTreeView ) i obtain the content of this folder in the right side ( in QListView )
please help me ........:confused:
http://img388.imageshack.us/img388/8519/fff.png
thanks
Re: how use QFileSystemModel with QListView ?
Hi, again
here what i do to obtain a folder path
Code:
{
String paren,child; //put the final path in child
Object dt = mdir.data(i);
child = dt.toString();
while(par != null)
{
paren = par.data().toString();
child = paren +"/"+ child;
par = par.parent();
}
return child;
}
so, i want to show the files of this path in QListView with QFileSystemModel
but i don't know how this model works !!!!!
Code:
public void show_file(String path)
{
QFileSystemModel std = new QFileSystemModel();
std.setRootPath(dir.path());
ui.listView.setUniformItemSizes(true);
ui.listView.setModel(std);
}
but this function doesn't works °° :confused:
thanks ...
Re: how use QFileSystemModel with QListView ?
Re: how use QFileSystemModel with QListView ?
Hi again :)
i found the solution of this bug
this's a part of code to display the content of a folder
Code:
public void show_file(String Path)
{
//initialization of fileSystem Model and Dir path
QFileSystemModel std = new QFileSystemModel();
// to arrange the items
ui.listView.setUniformItemSizes(true);
// join the model to the listView
ui.listView.setModel(std);
ui.listView.setRootPath(std.index(dir.path()));
}
Have a good time ;)
Re: how use QFileSystemModel with QListView ?
Line 12 of the code above: "setRootPath" is not a method of QListView, but a method of the QFileSystemModel. Can you please correct that line?