PDA

View Full Version : file and diretory view



hbill
22nd March 2008, 11:54
hi
I would like create a files and diretoris view whith 5 columns.
how can i use QTreeWidget or QListWidget to do that ?
thanks

wysota
22nd March 2008, 11:59
Try using QDirModel and QTableView.

hbill
22nd March 2008, 12:39
thanks
can i use QTreeWidget and QDirModel ?

wysota
22nd March 2008, 13:35
No, you can't. What do you need QTreeWidget for? You can use QTreeView instead of the table view if you want.

hbill
22nd March 2008, 14:20
i will use it in a ftp client, to view a local and server files ...
so i need a name, path and many informations of treewidget items to use with Qftp class

thanks

wysota
22nd March 2008, 14:39
Use QTreeView with QDirModel as suggested.

hbill
22nd March 2008, 15:47
If i use for exampl a mouse event, how can i identify which item on the treeview is clicked ?
for exampl on QTreeWidget (http://doc.trolltech.com/latest/qtreewidget.html) i can use my class


class myTreeWidget:public QTreeWidget


void mousePressEvent (QMouseEvent *event)
signals:
void itemClicked (QTreeWidgetItem *);
//......
void myTreeWidget::itemClicked(QMouseEvent * e)
{
QTreeWidgetItem *selectedItem = itemAt(e->pos());
emit itemClicked(selectedItem);
}
how can i use like this on QTreeView (http://doc.trolltech.com/latest/qtreeview.html)
thank you

wysota
22nd March 2008, 17:38
See QAbstractItemView::clicked

jay
27th August 2008, 12:35
Dear all,

I am using QTableView with QDirModel to display the local file system.

I have set the filter with "QDir::AllEntries". it is displaying all folders and Files including "." and ".." items.

If I use QDir::NoDotAndDotDot, both "." and ".." is filtered.

I need only ".." but not "."

can anyone suggest me the way of doing this.

Thanks in advance.

wysota
27th August 2008, 12:52
Apply a sort filter proxy model that will filter out the single dot.

jay
28th August 2008, 10:19
Dear all,

I have used QSortFilterProxyModel as per wysota's suggestion. its working fine. thanks for this.
can anyone help me with regular expression that should display only ".." not "."

proxyModel->setFilterRegExp ( QRegExp ( "......." ) );
proxyModel->setFilterKeyColumn ( 0 );

thanks in advance.

aamer4yu
28th August 2008, 10:52
Am not sure but
"[^\.]"
ie. Anything except '.' :)
Also have a look at QRegExp :)

ssaa
28th August 2008, 11:10
thanks for your reply.

I have checked with this, but it filters both ".." and "."

my requirement is only ".."

wysota
28th August 2008, 13:40
You can subclass the proxy and reimplement its filterAcceptsRow() method.

damonlin
18th November 2008, 15:53
It seems like an old article....:rolleyes:
But I have the same question about how to show files and directory of ftp.....
I choose QTreeView and QDirModel.....
What should I specify the parameters when I call QTreeView::setRootIndex() ??
Thanks.:)

wysota
18th November 2008, 17:18
QDirModel can't be used with FTP.