Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Solved - error: no matching function for call to 'QFileDialog::getOpenFileName()
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 8.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sprl111
    wrote on last edited by
    #1

    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()))
    

    .
    .
    .
    @

    1 Reply Last reply
    0
    • S Offline
      S Offline
      sprl111
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • D Offline
        D Offline
        DerManu
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0
        • S Offline
          S Offline
          sprl111
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          0
          • JeroentjehomeJ Offline
            JeroentjehomeJ Offline
            Jeroentjehome
            wrote on last edited by
            #5

            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!

            Greetz, Jeroen

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved