Results 1 to 5 of 5

Thread: QFileDialog accept() slot is not accessable

  1. #1
    Join Date
    Mar 2008
    Posts
    3
    Thanks
    1
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default QFileDialog accept() slot is not accessable

    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

    Qt Code:
    1. emit fileDialog->accept();
    To copy to clipboard, switch view to plain text mode 

    I have declared this signal in the header file with
    Qt Code:
    1. signals:
    2. void accept ();
    To copy to clipboard, switch view to plain text mode 

    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

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QFileDialog accept() slot is not accessable

    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.

  3. #3
    Join Date
    Mar 2008
    Posts
    3
    Thanks
    1
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: QFileDialog accept() slot is not accessable

    I tried this but I get the same error: 'virtual void QDialog::accept()' is protected

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QFileDialog accept() slot is not accessable

    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.

  5. The following user says thank you to wysota for this useful post:

    bigg (29th April 2008)

  6. #5
    Join Date
    Mar 2008
    Posts
    3
    Thanks
    1
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: QFileDialog accept() slot is not accessable

    Thanks. It is obvious now you have pointed that out. I will give that a go while I still have hair

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.