PDA

View Full Version : I want to modify/edit the QFileDialog dialog...



InterFan
19th June 2008, 07:54
Hi folks!

I'm new in Qt and I need to build a dialog which contains the SaveFileAs-alike feature, but, furthermore, in the same dialog, some ~10 informations widgets(most of them are strings and one of them is date).
in another word, I want to have the standard QFileDialog class dialog so I'll be able to further modify or edit it through the designer application.

Do you know what I mean?

I'm afraid that building such a dialog from scratch means huge amount of work-time, which I don't have.

I was trying to look in the internet and in the book called "C++ GUI Programming With Qt3", but couldn't find anything like that.

Regards.

BTW I've posted it in another forums system, so if I get an answer here or there, I'll quote it in the other forum.

Rayven
19th June 2008, 14:12
You can subclass the QFileDialog. Then pull out the layout( ) and place your widget(s) appropriatly:

QGridLayout *mainLayout = (QGridLayout *)layout( );
mpPropertiesGrp = new QGroupBox( tr( "Properties" ) );
mpPropertiesLayout = new QGridLayout( );
mpPropertyLbl = new QLabel( " " );
mpPropertyLbl->setAlignment( Qt::AlignTop | Qt::AlignLeft );
mpPropertiesLayout->addWidget( mpPropertyLbl, 0, 0, 3, 2 );
mpPropertiesGrp->setLayout( mpPropertiesLayout );
mainLayout->addWidget( mpPropertiesGrp, 0, 3, 4, 3 );


This snippit puts a Properties panel on the right hand side of the QFileDialog. This is using Qt4. The code would have to be modified a bit for Qt3. Hope this helps.

InterFan
25th June 2008, 16:51
Huge thanks!!

Although your code doesn't work(The setLayout() method said ti be a private one), maybe due to the differences between Qt3 and Qt4, it's very useful for as an example to start with and now I know where to focus and look in the documents without reading it from A to Z.

I'm trying to create my dialog now.

Thanks again!

Rayven
26th June 2008, 17:38
Whoops, I missed you were in Qt3.

The code example should still work. Basically you need to get the QFileDialog's layout
QGridLayout *layout = (QGridLayout *)fileDialog->layout( );

and then you can put in any widget into it. The setLayout( ) was for the QGroupBox.

InterFan
2nd July 2008, 08:56
Thanks a lot!!

God bless you :)

I can see QT is not really inferior to MFC, if at all, it just doesn't have immediate on-line documentation.

jacek
2nd July 2008, 12:58
it just doesn't have immediate on-line documentation.
Do you use Qt Assistant?

Rayven
2nd July 2008, 18:00
Thanks a lot!!

God bless you :)

I can see QT is not really inferior to MFC, if at all, it just doesn't have immediate on-line documentation.

Actually, I think the online/included API documentation and examples are wonderful compared to other toolkits I have used. http://doc.trolltech.com/ has all the API and examples for using Qt. All this documentation is included with the Qt bundles as well. Not to mention QtCentre for specific questions. I have NEVER had a more responsive forum, including MFC. Best of luck in your Qt endeavours!

InterFan
3rd July 2008, 08:02
Maybe it's my mistake, but while the Qt(including assistant which I do use) is great as a reference, it was much more difficult for me to 'get start quickly with zero knowledge" than with MFC which was immediate.