Results 1 to 7 of 7

Thread: No Match for Call

  1. #1
    Join Date
    Jun 2011
    Posts
    203
    Thanks
    7
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default No Match for Call

    Hi, I've got the following code:

    file1.h

    Qt Code:
    1. #include "file2.h"
    2. #include <QString>
    3.  
    4. struct ChartProperties
    5. {
    6. QString yvar;
    7. };
    To copy to clipboard, switch view to plain text mode 

    file1.cpp

    Qt Code:
    1. ChartProperties chart1;
    2. if(VariablePresent(chart1.yvar) //etc
    To copy to clipboard, switch view to plain text mode 

    file 2.h

    Qt Code:
    1. #include "file1.h"
    2. #include <QFile>
    3.  
    4. bool VariablesPresent(QString userVariable);
    To copy to clipboard, switch view to plain text mode 

    file2.cpp

    Qt Code:
    1. bool VariablesPresent(QString userVariable)
    2. {
    3. QFile cVariableEquivalents(//actual system path);
    4. if(!cVariableEquivalents().exists())
    5. //etc
    6. }
    To copy to clipboard, switch view to plain text mode 

    I may have missed one or two includes here or there... I've got them in my program, so the problem isn't with the includes I don't think.

    The error that I get at compile is:

    no match for call to '(QFile) ()'
    Any ideas on what I'm doing wrong?
    Last edited by Atomic_Sheep; 29th April 2012 at 11:01.

  2. #2
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: No Match for Call

    Can you show unmodified part of code that gives you this compilation error ?

  3. #3
    Join Date
    Feb 2008
    Posts
    491
    Thanks
    12
    Thanked 142 Times in 135 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: No Match for Call

    Quote Originally Posted by Atomic_Sheep View Post
    no match for call to '(QFile) ()'
    The problem is in file2.cpp line #4: cVariableEquivalents()

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: No Match for Call

    Line 3 of file2.cpp is in error. You have commented out the closing bracket so that once the pre-processor is finished with it the code reads:
    Qt Code:
    1. bool VariablesPresent(QString userVariable)
    2. {
    3. QFile cVariableEquivalents(
    4. if(!cVariableEquivalents().exists())
    5.  
    6. }
    To copy to clipboard, switch view to plain text mode 
    which clearly makes no sense. The brackets in that line are unnecessary anyway.

    Also, the function is called VariablesPresent() but you try to call VariablePresent(), which will not compile either.

  5. #5
    Join Date
    Jun 2011
    Posts
    203
    Thanks
    7
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: No Match for Call

    Ok, here's the unmodified version well excerpts at least:

    comparison.h

    Qt Code:
    1. #include <QMainWindow>
    2. #include <QFile>
    3. #include <QDir>
    4. #include <QString>
    5. #include <QTextStream>
    6. #include <QMessageBox>
    7. #include "ui_comparison.h"
    8. #include "filemanager.h"
    9.  
    10. public:
    11. struct ChartProperties
    12. {
    13. QString yAxisVariable;
    14. QString xAxisVariable;
    15. };
    To copy to clipboard, switch view to plain text mode 

    comparison.cpp

    Qt Code:
    1. #include "comparison.h"
    2.  
    3. if(VariablesPresent(sChart1.yAxisVariable) && VariablesPresent(sChart1.xAxisVariable))
    To copy to clipboard, switch view to plain text mode 

    P.S. the && part wasn't included when I tried to compile it, I've added it later on top of the error and currently am just waiting to get this error fixed to see if this && part is going to cause problems later on in the code.

    filemanager.h

    Qt Code:
    1. #include <QFile>
    2. #include <QDir>
    3. #include <QString>
    4. #include <comparison.h>
    5. #include <QTextStream>
    6.  
    7. bool VariablesPresent(QString userVariable);
    To copy to clipboard, switch view to plain text mode 

    filemanager.cpp

    Qt Code:
    1. #include "filemanager.h"
    2.  
    3. bool VariablesPresent(QString userVariable)
    4. {
    5. QFile cVariableEquivalents("/*directory*/");
    6. if(!cVariableEquivalents().exists())
    To copy to clipboard, switch view to plain text mode 

    etc...

    P.P.S. I'm not sure if bool is what I need but I'm using it for now, might change the function later on.
    Last edited by Atomic_Sheep; 2nd May 2012 at 10:41.

  6. #6
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: No Match for Call

    The problem is still, as norobro pointed out earlier, with line 6 of filemanager.cpp (formerly file2.cpp line 4). You are trying to call QFile::operator() and it doesn't exist, which is precisely what the compiler is telling you. The line should read:
    Qt Code:
    1. ...
    2. if(!cVariableEquivalents.exists())
    3. ...
    To copy to clipboard, switch view to plain text mode 
    but it will only do something sensible if line 5 actually contains something likely to be a file name.

  7. #7
    Join Date
    Jun 2011
    Posts
    203
    Thanks
    7
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: No Match for Call

    OOOOOH, thanks, simple fix... I just had to remove the () brackets from all subsequent uses and now it's all good, thanks.
    Last edited by Atomic_Sheep; 3rd May 2012 at 10:21.

Similar Threads

  1. Error: No match for call to '(QPoint)()'
    By GT Development in forum Qt Programming
    Replies: 5
    Last Post: 11th October 2011, 08:24
  2. QPainter error: no match for call ...
    By tonnot in forum Newbie
    Replies: 2
    Last Post: 7th October 2010, 12:00
  3. no match for 'operator=' in...
    By toss in forum Newbie
    Replies: 2
    Last Post: 14th April 2010, 00:08
  4. Replies: 1
    Last Post: 21st September 2009, 07:30
  5. No match for operator>>
    By Salazaar in forum Newbie
    Replies: 18
    Last Post: 12th June 2007, 17:48

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.