Results 1 to 13 of 13

Thread: expected constructor, destructor, or type conversion before '(' token

  1. #1
    Join Date
    Jul 2011
    Location
    Gurgaon
    Posts
    25
    Thanks
    4
    Qt products
    Qt3 Qt4
    Platforms
    Windows Symbian S60 Maemo/MeeGo

    Default expected constructor, destructor, or type conversion before '(' token

    Hi...

    I am using qnetworkaccessmanager.h header file at the top of main.cpp class in console application...

    and i am getting this error.....

    "expected constructor, destructor, or type conversion before '(' token"

    what could be the couse for this issue...
    plz help me..
    thanks

  2. #2
    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: expected constructor, destructor, or type conversion before '(' token

    A syntax error in your code, usually a missing semi-colon or #include, but without your code we cannot tell.
    "We can't solve problems by using the same kind of thinking we used when we created them." -- Einstein
    If you are posting code then please use [code] [/code] tags around it - makes addressing the problem easier.

  3. #3
    Join Date
    Jul 2011
    Location
    Gurgaon
    Posts
    25
    Thanks
    4
    Qt products
    Qt3 Qt4
    Platforms
    Windows Symbian S60 Maemo/MeeGo

    Default Re: expected constructor, destructor, or type conversion before '(' token

    Thanks for ur reply.. but when I click on the error .. it takes me to qnetworkaccessmanager.h file itself and
    the code is here
    Qt Code:
    1. DECLARE_INTERFACE_(IAMMediaContent, IDispatch)
    2. {
    3. STDMETHOD(get_AuthorName)(THIS_ BSTR*) PURE;
    4. STDMETHOD(get_Title)(THIS_ BSTR*) PURE;
    5. STDMETHOD(get_Rating)(THIS_ BSTR*) PURE;
    6. STDMETHOD(get_Description)(THIS_ BSTR*) PURE;
    7. STDMETHOD(get_Copyright)(THIS_ BSTR*) PURE;
    8. STDMETHOD(get_BaseURL)(THIS_ BSTR*) PURE;
    9. STDMETHOD(get_LogoURL)(THIS_ BSTR*) PURE;
    10. STDMETHOD(get_LogoIconURL)(THIS_ BSTR*) PURE;
    11. STDMETHOD(get_WatermarkURL)(THIS_ BSTR*) PURE;
    12. STDMETHOD(get_MoreInfoURL)(THIS_ BSTR*) PURE;
    13. STDMETHOD(get_MoreInfoBannerImage)(THIS_ BSTR*) PURE;
    14. STDMETHOD(get_MoreInfoBannerURL)(THIS_ BSTR*) PURE;
    15. STDMETHOD(get_MoreInfoText)(THIS_ BSTR*) PURE;
    16. };
    To copy to clipboard, switch view to plain text mode 

  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: expected constructor, destructor, or type conversion before '(' token

    What immediately precedes your #include <QNetworkAccessManager> line?

  5. #5
    Join Date
    Jul 2011
    Location
    Gurgaon
    Posts
    25
    Thanks
    4
    Qt products
    Qt3 Qt4
    Platforms
    Windows Symbian S60 Maemo/MeeGo

    Default Re: expected constructor, destructor, or type conversion before '(' token

    Thanks for ur reply.. but when I click on the error .. it takes me to qnetworkaccessmanager.h file itself and
    the code is here..

    Qt Code:
    1. DECLARE_INTERFACE_(IAMMediaContent, IDispatch)
    2. {
    3. STDMETHOD(get_AuthorName)(THIS_ BSTR*) PURE;
    4. STDMETHOD(get_Title)(THIS_ BSTR*) PURE;
    5. STDMETHOD(get_Rating)(THIS_ BSTR*) PURE;
    6. STDMETHOD(get_Description)(THIS_ BSTR*) PURE;
    7. STDMETHOD(get_Copyright)(THIS_ BSTR*) PURE;
    8. STDMETHOD(get_BaseURL)(THIS_ BSTR*) PURE;
    9. STDMETHOD(get_LogoURL)(THIS_ BSTR*) PURE;
    10. STDMETHOD(get_LogoIconURL)(THIS_ BSTR*) PURE;
    11. STDMETHOD(get_WatermarkURL)(THIS_ BSTR*) PURE;
    12. STDMETHOD(get_MoreInfoURL)(THIS_ BSTR*) PURE;
    13. STDMETHOD(get_MoreInfoBannerImage)(THIS_ BSTR*) PURE;
    14. STDMETHOD(get_MoreInfoBannerURL)(THIS_ BSTR*) PURE;
    15. STDMETHOD(get_MoreInfoText)(THIS_ BSTR*) PURE;
    16. };
    To copy to clipboard, switch view to plain text mode 

    my header section is:

    Qt Code:
    1. #include <QtCore/QCoreApplication>
    2. #include <iostream>
    3. #include <conio.h>
    4. #include <stdio.h>
    5. #include <qnetwork.h>
    6. #include <qnetworkaccessmanager.h>
    To copy to clipboard, switch view to plain text mode 

  6. #6
    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: expected constructor, destructor, or type conversion before '(' token

    Can you post the whole main.cpp and error message (including line number) ?

  7. #7
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Thanks
    5
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: expected constructor, destructor, or type conversion before '(' token

    The source you posted is <qnetwork.h> and it isn't a Qt header file.
    A camel can go 14 days without drink,
    I can't!!!

  8. #8
    Join Date
    Jul 2011
    Location
    Gurgaon
    Posts
    25
    Thanks
    4
    Qt products
    Qt3 Qt4
    Platforms
    Windows Symbian S60 Maemo/MeeGo

    Default Re: expected constructor, destructor, or type conversion before '(' token

    My main.cpp is
    Qt Code:
    1. #include <QtCore/QCoreApplication>
    2. #include <iostream>
    3. #include <conio.h>
    4. #include <stdio.h>
    5. #include <qnetwork.h>
    6. #include <qnetworkaccessmanager.h>
    7.  
    8. int main(int argc, char *argv[])
    9. {
    10. QCoreApplication a(argc, argv);
    11. QNetworkAccessManager *manager = new QNetworkAccessManager(this);
    12.  
    13.  
    14. return a.exec();
    15. }
    To copy to clipboard, switch view to plain text mode 

    and error messages are

    c:\qtsdk\mingw\bin\..\lib\gcc\mingw32\4.4.0\..\..\ ..\..\include\qnetwork.h:16: error: expected constructor, destructor, or type conversion before '(' token

  9. #9
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Thanks
    5
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: expected constructor, destructor, or type conversion before '(' token

    Quote Originally Posted by cuteatul View Post
    My main.cpp is
    Qt Code:
    1. #include <QtCore/QCoreApplication>
    2. #include <iostream>
    3. #include <conio.h>
    4. #include <stdio.h>
    5. #include <qnetwork.h>
    6. #include <qnetworkaccessmanager.h>
    7.  
    8. int main(int argc, char *argv[])
    9. {
    10. QCoreApplication a(argc, argv);
    11. QNetworkAccessManager *manager = new QNetworkAccessManager(this);
    12.  
    13.  
    14. return a.exec();
    15. }
    To copy to clipboard, switch view to plain text mode 

    and error messages are

    c:\qtsdk\mingw\bin\..\lib\gcc\mingw32\4.4.0\..\..\ ..\..\include\qnetwork.h:16: error: expected constructor, destructor, or type conversion before '(' token
    the problem is in the <qnetwork.h> file, try compile your main without including it.
    A camel can go 14 days without drink,
    I can't!!!

  10. #10
    Join Date
    Jul 2011
    Location
    Gurgaon
    Posts
    25
    Thanks
    4
    Qt products
    Qt3 Qt4
    Platforms
    Windows Symbian S60 Maemo/MeeGo

    Default Re: expected constructor, destructor, or type conversion before '(' token

    Ya then it compiles successfully....
    but qnetwork.h is not hard coded file ... it is a predefined file.....
    so how should I look for errors in this file..................?????

  11. #11
    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: expected constructor, destructor, or type conversion before '(' token

    Firstly, if your program compiles without it then you don't need it, and don't need to correct errors in it.

    Secondly, as advised earlier, qnetwork.h is not part of Qt. It has dependencies that you are missing before the include, specifically:
    To define the interface identifier, include the header file Initguid.h before Qnetwork.h, but after Dshow.h and other header files:
    Qt Code:
    1. #include <dshow.h>
    2. #include <initguid.h>
    3. #include <qnetwork.h>
    To copy to clipboard, switch view to plain text mode 
    Note Make sure that Initguid.h is included only once in your project. Otherwise, you will receive linker errors for duplicate GUID values.
    as in the Microsoft docs clearly states. If there are errors internal to that file (I strongly doubt it) then you need to address that with the author.

  12. #12
    Join Date
    Jul 2011
    Location
    Gurgaon
    Posts
    25
    Thanks
    4
    Qt products
    Qt3 Qt4
    Platforms
    Windows Symbian S60 Maemo/MeeGo

    Default Re: expected constructor, destructor, or type conversion before '(' token

    Thanks.. it solves my problem.... But after doing this I am getting one error ... here is

    c:\qtsdk\mingw\bin\..\lib\gcc\mingw32\4.4.0\..\..\ ..\..\include\qnetwork.h:46: error: expected unqualified-id before '}' token

    and I want to be clear about if qnetwork.h is a part of qt framework or not.......

  13. #13
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: expected constructor, destructor, or type conversion before '(' token

    <qnetwork.h> is not.. Qt has <QtNetwork>

Similar Threads

  1. expected `)' before '*' token
    By vinod sharma in forum Qt Programming
    Replies: 3
    Last Post: 15th March 2010, 08:57
  2. Replies: 4
    Last Post: 9th September 2009, 10:02
  3. Expected class-name before '{' token
    By imagiro1 in forum Newbie
    Replies: 16
    Last Post: 16th June 2009, 12:37
  4. error: expected class-name before '{' token
    By Aresti in forum Qt Programming
    Replies: 1
    Last Post: 12th November 2008, 21:00
  5. expected initializer before »)« token
    By Holy in forum Qt Programming
    Replies: 2
    Last Post: 24th May 2008, 17:24

Tags for this Thread

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.