PDA

View Full Version : QFileDialog accept() slot is not accessable



bigg
29th April 2008, 09:40
I am using an instance of QFileDialog so a user can search for a directory that meets a specific criteria. When the directory signature is recognised by my code, I want to use


emit fileDialog->accept();

I have declared this signal in the header file with

signals:
void accept ();

so the user does not have to press the OK button. This will save the user time traversing directories.

When I try to compile with this line, I get an error: 'virtual void QDialog::accept()' is protected

Why is this compilation error occuring when QFileDialog is a sub class of QDialog?.
What can I do to get this code to work?

Any suggestions will be greatly appreciated. Thanks

wysota
29th April 2008, 09:53
accept() is a slot, not a signal. Why don't you just call accept() from the dialog? Not as a signal but as a regular method.

bigg
29th April 2008, 11:22
I tried this but I get the same error: 'virtual void QDialog::accept()' is protected

wysota
29th April 2008, 11:30
Because it is protected in QFileDialog... You may only call it from within the dialog itself. You'll have to subclass QFileDialog and place your code there.

bigg
29th April 2008, 11:35
Thanks. It is obvious now you have pointed that out. I will give that a go while I still have hair