FtpDirModel

Qt provides a QDirModel class that makes it easy to display directory structures in a view. For a project that we are working on, we needed a model that would make it easy to display the structure of a FTP directory. Thats exactly what we have in FtpDirModel right now. Using the FtpDirModel class is very simple,

#include <QApplication>
#include <QTreeView>

#include "FtpDirModel.h"

int main(int argc, char** argv)
{
QApplication a(argc, argv);

FtpDirModel model;
model.setUrl(QUrl("ftp://ftp.trolltech.com"));

QTreeView view;
view.setModel(&model);
view.show();

return a.exec();
}

Upon executing the above program, you will see a QTreeView that shows the directory structure of ftp.trolltech.com.

While the model is fetching data for a directory, it shows a nice “Fetching…” text in the first column :-).

Take a look at the code. You can checkout a copy from here: https://svn2.hosted-projects.com/vcreatelogic/FtpDirModel. Username and password is anonymous.


Posted

in

by

Tags: