Hi
I am sending u the code Please tell me its right or not for the representation of path in a tree structure form.
actually I got " segmentationfault "
Here the code is
#include <qfiledialog.h>
#include <qapplication.h>
#include <qlistview.h>
#include <qstring.h>
#include <qfile.h>
#include <qfileinfo.h>
#include <qstringlist.h>
#include<qmessagebox.h>
#include <qpixmap.h>
#include <qcheckbox.h>
#include <qdir.h>
#include <qstringlist.h>
#include <qmessagebox.h>
void Form1::fileOpen()
{
"/",
this,
"get existing directory",
"Choose a directory",
TRUE );
setDir(m_source);
}
{
QListViewItemIterator it(listView);
++it;
for(;it.current();++it)
{
it.current()->setOpen(FALSE);
}
QListViewItem * item;
item->firstChild();
slist=dir.entryList();
for(;it2!=slist.end();++it2)
{
while(item)
{
if(item->text(0)=*it2)
{
item->setOpen(TRUE);
break;
}
item=item->itemBelow();
}
}
if ( item )
listView->setCurrentItem( item );
}
#include <qfiledialog.h>
#include <qapplication.h>
#include <qlistview.h>
#include <qstring.h>
#include <qfile.h>
#include <qfileinfo.h>
#include <qstringlist.h>
#include<qmessagebox.h>
#include <qpixmap.h>
#include <qcheckbox.h>
#include <qdir.h>
#include <qstringlist.h>
#include <qmessagebox.h>
void Form1::fileOpen()
{
m_source = QFileDialog::getExistingDirectory(
"/",
this,
"get existing directory",
"Choose a directory",
TRUE );
setDir(m_source);
}
void Form1::setDir(QString path)
{
QListViewItemIterator it(listView);
++it;
for(;it.current();++it)
{
it.current()->setOpen(FALSE);
}
QStringList slist;
QDir dir(path);
QListViewItem * item;
item->firstChild();
slist=QStringList::split("/",path);
slist=dir.entryList();
QStringList::Iterator it2=slist.begin();
for(;it2!=slist.end();++it2)
{
while(item)
{
if(item->text(0)=*it2)
{
item->setOpen(TRUE);
break;
}
item=item->itemBelow();
}
}
if ( item )
listView->setCurrentItem( item );
}
To copy to clipboard, switch view to plain text mode
If there is some alterations in this code then also tell me.
Thanx
Bookmarks