PDA

View Full Version : Problem in the QFileDialog



joseph
6th December 2006, 07:31
Hai guys,


Version : Qt 3.3.4
Problem : Problem in the MODEL property of a QFileDialog



I have the following windows or objects in screen:-

1. MyMainWindow
2. MyWizard ( textBox, BrowseButton , CancelButton.. )
3. QFileDialog

The parent-child realation is setted in the same order as above.

While Applicaitons loads the following will be the senario.....
1. MyMainWindow comes
2. while clicking one menu , MyWizad comes with a BROWSE-BUTTON
3. While clicking on BROWSE-BUTTON , the below method <code> saveInputDataToFile ( const QString& inputName, const Q_ULLONG& inputSize, QWidget* parent ) </code> will be invoked to popup a QFileDilog


void MyMainWindow :: saveInputDataToFile( const QString& inputName, const Q_ULLONG& inputSize , QWidget* parent )
{
-------
// parent = MyWizard object
QFileDialog * obj = new QFileDialog ( parent , "", true) ;

QString destFilePath = obj->getSaveFileName( QString::null, QString::Null, parent );
-------
}



My problem is that .....

1 .While showing the " QFileDialog ", if am clicking on the MyMainWindow ,
2. then the MyWizard's ( shows in between MyMainWindow and QFileDialog ) window highlighted , cursor will be in the wizard ( in a textBox near to BrowseButton )
3. and we can access BUTTONS using tab Key. Even we can CLOSE that Wizard using KEYBOARD, At the same time we can see the QFileDialog in the screen with out MyWizard


I want to restrict this KEYBORD access in MyWizard...please help me


Thank You.

wysota
6th December 2006, 08:53
What is "parent" in the above code?

joseph
6th December 2006, 09:28
void MyMainWindow :: saveInputDataToFile( const QString& inputName, const Q_ULLONG& inputSize , QWidget* parent )
{
-------
// Parent = MyWizard ;

QFileDialog * obj = new QFileDialog ( parent , "", true ) ;

QString destFilePath = obj->getSaveFileName( QString::null, QString::Null, parent );
-------
}



This is the parent -child flow....
+--------------------------+
| MyMainWindow |
+----------^--------------+
|
+---------------------------+
| MyWizard |
+-----------^--------------+
|
+--------------------------+
| QFileDialog |
+--------------------------+

wysota
6th December 2006, 10:32
getSaveFileName is a static method, please use it as one.


QString dest = QFileDialog::getSaveFileName(parent);

joseph
6th December 2006, 10:51
i have tried this also


void MyMainWindow :: saveInputDataToFile( const QString& inputName, const Q_ULLONG& inputSize , QWidget* parent )
{
-------
QString destFilePath = QFileDialog::getSaveFileName( ..., .., ..., ..., parent );

-------
}




But at this time also the keyboard is working in MyWizard ...and i can even close it by using TAB-KEY , without closing the FileDialog


please help me...

wysota
6th December 2006, 11:03
Are you sure "parent" is set to the wizard? Can you confirm that? (for example by using
parent->metaObject()->className()

Edit: The attached code works correctly for me (compile using qmake -project && qmake && make)

sunil.thaha
6th December 2006, 13:00
You once again missed that it is related to Qt3

joseph
6th December 2006, 13:12
I confirmed that , " QFileDialog's " parent is " QMyWizard " in run time.
I have debugged the code it shows ....





void MyMainWindow :: saveInputDataToFile( const QString& inputName,
const Q_ULLONG& inputSize ,
QWidget* parent )

{

-------
const char * Name = parent->className();
// in run time the Name is MyWizard.

QString destFilePath = QFileDialog::getSaveFileName( ..., .., ..., ..., parent );



-------

}




I think i have to do some thing else ...


Thank you so much for sparing your time for me

wysota
6th December 2006, 21:40
You once again missed that it is related to Qt3

So? Does it matter? The code is practically the same and works the same, here - try it.

wysota
6th December 2006, 21:42
I think i have to do some thing else ...

Is the wizard a QDialog subclass (note that QWizard is QDialog subclass as well)?

Try the code I attached in the previous post, it should work for you. If it doesn't you'll know you have a buggy Qt installation. If it does, maybe it'll help you correct your code.

sunil.thaha
7th December 2006, 06:31
So? Does it matter? The code is practically the same and works the same, here - try it.
It does not matter to you or to me. But the question is does it matter to him ?

wysota
7th December 2006, 09:56
It does not matter to you or to me. But the question is does it matter to him ?

The question was asked in "Qt programming" section, not in the "Newbie" section so I can assume that the person asking the question has some skills to modify the code so that it fits Qt3. The only changes required were modifying the includes and the file dialog line. Anyway, just to make things clear, I didn't use Qt4 code on purpose, I just didn't notice one was using Qt3.