Solved - error: no matching function for call to 'QFileDialog::getOpenFileName()



  • Hello,

    I'm getting this error,

    error: no matching function for call to 'QFileDialog::getOpenFileName(Ui::MainWindow*&, const char [14], const char [10], const char [26])'

    The relevenat code snippit is below. Anyone have any clues as to why I'm getting this error? Can QFileDialog::getOpenFileName() be called from any class as long as I give it a pointer to a QWidget?

    Thanks.

    @
    #include <QFileDialog>

    .
    .
    .

    // DINIBOARD -> DINIBOARD class constructor
    DINIBOARD::DINIBOARD @(Ui::MainWindow *gui){
    this->gui = gui;
    .
    .
    .

    filename = QFileDialog::getOpenFileName(gui, "Open Bit File", "/bitfiles", "FPGA Bit Files (*bit *.*)");
    if((!filename->isNull()))
    

    .
    .
    .
    @



  • Well, I think I figured this out. MainWindow class is the QWidget not Ui::MainWindow. However the parent to Ui::MainWindow seems to have all the QWidget definitions.



  • Does it work when passing 0 as parent (first argument) ?



  • Thank you for responding. I'm now passing a pointer to MainWindow to the class and using that as the QWidget in QDialog. The compile error went away. Then to access the various QWigets in the MainWindow, I made the pointer to Ui::MainWindow that is stored in MainWindow public and then doing pointer to pointer to QWidget. I'm not sure what passing a zero or null as a parent will do. I'll try that when I get time.



  • The parent "owns" the dialog. So if the dialog is still open you can't click the mainwindow (parent), this is set as default, but can be changed. The dialog will blink if clicked on the mainwindow. It is a good way to prevent opening the same dialog again and again and again. You freeze the program until the dialog is closed again. For example use Word to open a file, then click save and try to click the document while the save dialog is still open.
    Happy coding!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.