Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 5

Qt-interest Archive, April 2007
Cancel signal for modeless QFileDialog ?


Message 1 in thread

Hello,

I use QFileDialog in modeless (non modal) mode with QT 3.3.x. I want to 
have two signals from this dialog :
-> One when a file is selected and the user press "Save" or "Read" 
button. This signal already exists ("fileSelected()") and works fine.
-> An other one when the user closes the file selection dialog without 
pressing "Save" or "Read" button. This signal doesn't seems to exist, so 
I am unable to know whether the file dialog is still alive or not.


I tried to subclass QFileDialog in order to emit a "cancel()" signal 
whenever closeEvent() & hideEvent() are called.
It works fine but this signal is also emited when I click "Save" button 
which is not ok ...
Then I tried to test "result()" function return value, but this function 
returns a wrong value in modeless mode (in fact the value is updated 
after the closeEvent() call).

Here is the code of the subclassed closeEvent() function :
void IREFileDialog::closeEvent(QCloseEvent * event)
	{
	if(result() == QFileDialog::Rejected) emit(cancel());
	QFileDialog::closeEvent(event);
	}


To sum-up, the question is : how to emit a "cancel()" signal with 
QFileDialog when and ONLY when the user press the "Cancel" button or the 
cross ?

Thanks for your help,
						Xavier

--
 [ signature omitted ]