PDA

View Full Version : qtreeview -file path



onder
12th July 2006, 08:59
hi ,
i am writing treeview code like this. this code displaying all file
in my computer and then when i was click this item in treview
for example this message apper : /user
but i need all path this file like this : /home/user/a.txt...

thanks alot
Onder


treeDosyalar = new QTreeView();
model = new QDirModel();
treeDosyalar->setModel(model);

connect(treeDosyalar, SIGNAL(doubleClicked(QModelIndex)),this,

SLOT(treeAc(QModelIndex)));

void treeAc(QModelIndex qm)
{
QString text = qm.parent().data(0).toString();
QMessageBox::information(this, "Mesaj", text);
}

jpn
12th July 2006, 09:05
Try these methods:
QFileInfo QDirModel::fileInfo (http://doc.trolltech.com/4.1/qdirmodel.html#fileInfo) ( const QModelIndex & index ) const
QString QDirModel::fileName (http://doc.trolltech.com/4.1/qdirmodel.html#fileName) ( const QModelIndex & index ) const
QString QDirModel::filePath (http://doc.trolltech.com/4.1/qdirmodel.html#filePath) ( const QModelIndex & index ) const

onder
12th July 2006, 09:29
i am trying : QDirModelFilePath like this



void treeAc(const QModelIndex qm)
{
QString text1 = QDirModel::filePath(qm);
QMessageBox::information(this, "Mesaj", text1);
}

but i am taking this error :

form.h:54: error: cannot call member function `QString QDirModel::filePath(const
QModelIndex&) const' without object

whats wrong, thanks alot

Onder

onder
12th July 2006, 09:40
sorry i found. thank you

onder