PDA

View Full Version : Howto create custom File Browser view



f1ns
21st February 2013, 15:01
Hello,
I am new to Qt and would like to ask your help in implement the following features:

A file browser that accepts comments and tags about the file(s) that are being displayed. Double clicking on the entry should open the file (which can be assumed to be text only) for editing via an inbuilt editor.


P.S: I just started programming in QT a few hours ago and am fairly new to python programming too.


Regards,
f1ns

d_stranz
21st February 2013, 17:29
A file browser that accepts comments and tags about the file(s) that are being displayed.

What do you mean by this? That the user can select a file, and then somehow add comments or tags? Or the file already has comments and tags (that were added somehow by another means) and you want to display those when the user selects (and hovers) on the file name?


P.S: I just started programming in QT a few hours ago

And you are already trying to implement a custom file browser? I guess you don't believe in learning to walk before you start out running at full speed. ;)

f1ns
22nd February 2013, 04:18
What do you mean by this? That the user can select a file, and then somehow add comments or tags?

Yes


Or the file already has comments and tags (that were added somehow by another means) and you want to display those when the user selects (and hovers) on the file name?

A user can add comments and tags to a file using my interface and that can be used when searching for files (using just my app). There is a another separate interface for deleting already existing tags/comments.



And you are already trying to implement a custom file browser? I guess you don't believe in learning to walk before you start out running at full speed. ;)
No, i am trying to fight for QT. AFAIK things like this are easier to do in HTML xD.

d_stranz
22nd February 2013, 16:15
I presume you understand that you need some external mechanism for associating the comments and other attributes with the files, like a database or some other local file created in the directory that will hold this extra information. I don't believe there is a generic (i.e OS-independent) way to do this.

I would start by looking at the signals emitted by QFileDialog, especially currentChanged() and directoryEntered(). currentChanged() is the handle you need to tell you which file the user has clicked on. In a slot that handles this, you might create a tooltip that displays the current information, or a right-click "properties" menu that posts a new dialog to allow the user to add or edit comments and tags. In the slot that handles directoryEntered(), you know where you are in the file system and can look up cached information for that directory.

QFileDialog is of course used for file selection, but the code contains all the functions needed for traversing the file system and notifying the app about what the user is up to. You could use it as the basis for a custom browser.