You are not logged in.

TallMonke

Beginner

  • "TallMonke" is male
  • "TallMonke" started this thread

Posts: 20

Location: Ohio

Occupation: Software Engineer

  • Send private message

1

Thursday, March 24th 2005, 6:19pm

Custom File Dialog

Is there a way to use the QFileDialog to create a custom file dialog? I need to be able to put a "file information" section on the right hand side of the window...

Thanks
The world is like a box of chocolate,
and I am the nut! :]

This post has been edited 1 times, last edit by "TallMonke" (Mar 28th 2005, 3:54pm)


Posts: 2,162

Location: Graz, Austria

Occupation: Student

  • Send private message

2

Thursday, March 24th 2005, 7:02pm

Qt/KDE Developer
Debian User

TallMonke

Beginner

  • "TallMonke" is male
  • "TallMonke" started this thread

Posts: 20

Location: Ohio

Occupation: Software Engineer

  • Send private message

3

Thursday, March 24th 2005, 8:13pm

Can you use a layout to define the Widget that gets set into the preview? For instance, I am creating a QVBoxLayout object and populating it with various things, including a push button. So far I cant get anything to display in the preview, and I cannot define a signal/slot for the button.

If you can do these things, then this is what I was looking for. Else, I will need to define my own open dialog...
The world is like a box of chocolate,
and I am the nut! :]

TallMonke

Beginner

  • "TallMonke" is male
  • "TallMonke" started this thread

Posts: 20

Location: Ohio

Occupation: Software Engineer

  • Send private message

4

Friday, March 25th 2005, 2:07pm

Answer...

I finally figured out to use the addWidgets() function of QFileDialog to add a 2 labels and a button to the bottom of the open file dialog. I first had to inherit from QFileDialog in my class, then called the addWidgets in the constructor. Not exactly what I had in mind, but it works.
The world is like a box of chocolate,
and I am the nut! :]

chickenblood

Professional

Posts: 657

Location: Mountain View, CA

Occupation: Data Monkey

  • Send private message

5

Sunday, March 27th 2005, 10:09pm

RE: Answer...

Quoted

Originally posted by TallMonke
I finally figured out to use the addWidgets() function of QFileDialog to add a 2 labels and a button to the bottom of the open file dialog. I first had to inherit from QFileDialog in my class, then called the addWidgets in the constructor. Not exactly what I had in mind, but it works.


What exactly did you have in mind?
I have enough sense to know that "common sense" is an oxymoron.

TallMonke

Beginner

  • "TallMonke" is male
  • "TallMonke" started this thread

Posts: 20

Location: Ohio

Occupation: Software Engineer

  • Send private message

6

Monday, March 28th 2005, 3:44pm

RE: Answer...

I originally wanted the labels on the right hand side of the QOpenFileDialog instead of the bottom. But inheriting only allows for a single label to be placed on the right or left hand side of the dialog.
The world is like a box of chocolate,
and I am the nut! :]

chickenblood

Professional

Posts: 657

Location: Mountain View, CA

Occupation: Data Monkey

  • Send private message

7

Monday, March 28th 2005, 4:51pm

RE: Answer...

As any_skoa mentioned in a previous email, you can easily do what you want with setInfoPreview() or setContentsPreview().

It is true that it allows for a single widget. However, you can have as many labels, buttons or whatever you like within this widget. Use a QVBox for example and put your labels into it.

No problem at all.
I have enough sense to know that "common sense" is an oxymoron.

This post has been edited 1 times, last edit by "chickenblood" (Mar 28th 2005, 8:16pm)


TallMonke

Beginner

  • "TallMonke" is male
  • "TallMonke" started this thread

Posts: 20

Location: Ohio

Occupation: Software Engineer

  • Send private message

8

Tuesday, March 29th 2005, 8:03pm

I implemented the SetInfoPreview that was been mentioned. However, when I click on a new file, the preview information does not redraw? is there something that I am missing? This is not the end result, but just a check to see if it works...

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
class FilePreview : public QVBox, public QFilePreview
{
public:
   FilePreview( QWidget *parent = 0 ) : QVBox( parent ) {}

   void previewUrl( const QUrl &u )
   {
      QLabel *fileTypeLbl;

      QString path = u.path();
      
      setCaption( "File Information:" );

      new QLabel( tr( "File Type:" ), this );
      fileTypeLbl = new QLabel( path, this );
   }
};
The world is like a box of chocolate,
and I am the nut! :]

chickenblood

Professional

Posts: 657

Location: Mountain View, CA

Occupation: Data Monkey

  • Send private message

9

Tuesday, March 29th 2005, 8:41pm

previewUrl() should be called whenever a new file is selected.

Your current implementation will result in very strange behaviour! You should create your widgets in the constructor of your class, not the previewUrl() method.
I have enough sense to know that "common sense" is an oxymoron.

This post has been edited 1 times, last edit by "chickenblood" (Mar 29th 2005, 8:42pm)


TallMonke

Beginner

  • "TallMonke" is male
  • "TallMonke" started this thread

Posts: 20

Location: Ohio

Occupation: Software Engineer

  • Send private message

10

Tuesday, March 29th 2005, 8:45pm

The "strange behavior" is that a new QVBox get placed alongside the existing one, but nothing gets redrawn until you deselect the preview box, then reselect again, then there is the updated information under the previous information.

Thanks for the help chickenblood!!
The world is like a box of chocolate,
and I am the nut! :]

chickenblood

Professional

Posts: 657

Location: Mountain View, CA

Occupation: Data Monkey

  • Send private message

11

Tuesday, March 29th 2005, 10:29pm

So did you sort it out, or do you still need help?
I have enough sense to know that "common sense" is an oxymoron.

TallMonke

Beginner

  • "TallMonke" is male
  • "TallMonke" started this thread

Posts: 20

Location: Ohio

Occupation: Software Engineer

  • Send private message

12

Wednesday, March 30th 2005, 2:36pm

I got it all figured out. Thanks so much for the help!!
The world is like a box of chocolate,
and I am the nut! :]