Hi guys,
I am trying to make a filebrowser application with the help of QListView and QDir classes of Qt2 designer with Qtopia 2.2.0. I have drawn a QListView widget named MyListView on UI.
I declared a QDir dir globally;
i wrote my progrm as follows...
#include "browser.h" //my header file
#include <qdir.h>
#include <qlistview.h>
#include <qstringlist.h>
QDir dir=QDir::rootDirPath();
Browser::Browser(QWidget *parent,const char *name, WFlags fl):
BrowserForm(parent,name,fl)
{
QListViewItem *rootItem=new QListViewItem(MyListView);
rootItem->setText(0,QDir::rootDirPath());
MyListView->insertItem(rootItem);
connect(MyListView,SIGNAL(doubleClicked(QListViewI tem*),this,SLOT(setDir(QListViewItem*)));
connect(upButton,SIGNAL(clicked()),this,SLOT(upPat h());
}
Browser::~Browser()
{
}
void Browser::setDir(QListViewItem* newItem)
{
MyListView->clear();
QStringList dirList(dir.entryList());
for(QStringList::Iterator it=dirList.begin();it!=dirList.end();++it)
{
QListViewItem *dirItem=new QListViewItem(MyListView);
dirItem->setText(0,(*it));
MyListView->insertItem(dirItem);
}
}
void Browser::upPath()
{
MyListView->clear();
QListViewItem *upitem=new QListViewItem(MyListView);
upItem->setText(0,dir.path());
MyListView->insertItem(upItem);
}
This code compiles fine. when i clicke the root folder set in the listview i get to see the subfolders and when i press the up button i again see the rootfolder. This works fine for the root and its subsequent folders. But i am unable to understand what i have to do if i have to click one of the subfolders randomly and see the subfolders of the subfolder selected. Also how to set the path for up function if i have to come back from the subfolders level by level....
The Qtopia 2.2.0 doesn't have much API to manipulate random dir path. What to do???
Bookmarks