PDA

View Full Version : File Open dialog with preview?



will49
24th July 2007, 17:00
I'm looking for a file open dialog that allows a custom preview of the contents file selected in the dialog. Kind of like what Photoshop and other applications did. Preview can be either text or graphical.

Does Qt have anything like that? If not, any pointers on the best way to go about making one?

Thanks

marcel
24th July 2007, 18:00
Qt does not have it. You must implement it yourself.

It is not easy to say how to achieve this.
Photoshop does everything internal.

So, I guess this is the best way to do it. This is how I'd do it.

Regards

fullmetalcoder
24th July 2007, 18:08
Should be easy enough :

Create a custom preview widget
Add it to the dialog :
fileOpenDialog.layout()->addWidget(new MyPreviewWidget) (a bit of testing may be necessary here to fine tune the look...
connect the dialog signals to appropriate slots of your preview widget so as to update its content...I myself hacked a similar preview widget (but not for use with this dialog). The code was a bit crappy but if you want I can send it to you so that you have an idea of how to get started...

To allow displaying different types of content I would recommend using a stacked widget with a label for images, a text edit/text browser for text files, ...