Results 1 to 4 of 4

Thread: Error declaring Qt object

  1. #1
    Join Date
    Jan 2006
    Location
    Berkeley California
    Posts
    109
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Error declaring Qt object

    If I try to declare a QDirModel pointer in my class declaration in my header (QDirMidel* pDirModel), I get the error "ISO C++ forbids declaration of 'QDirModel' with no type".

    If I declare other objects (e.g., QPainter* pPainter), I get no such error.

    ???
    Thanks

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Error declaring Qt object

    Try a forward declaration at the beginning of your header, after the include section:
    Qt Code:
    1. class QDirModel;
    To copy to clipboard, switch view to plain text mode 

    Note that in the cpp you have to include QDirModel.

    Regards

  3. The following user says thank you to marcel for this useful post:

    mgulsoy (26th June 2009)

  4. #3
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Error declaring Qt object

    Depending on your needs, either forward declare:
    Qt Code:
    1. class QDirModel;
    To copy to clipboard, switch view to plain text mode 
    or include the header:
    Qt Code:
    1. #include <QDirModel>
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  5. #4
    Join Date
    Jan 2006
    Location
    Berkeley California
    Posts
    109
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Error declaring Qt object

    Thanks very much !

Similar Threads

  1. Getting std::string object from QString object ( qt3)
    By joseph in forum Qt Programming
    Replies: 11
    Last Post: 28th March 2013, 21:09
  2. Replies: 8
    Last Post: 27th August 2007, 16:45
  3. Sending simple object via udp...with a twist
    By the scribe in forum Qt Programming
    Replies: 1
    Last Post: 6th June 2007, 11:16
  4. QT Designer? Coding by hand?
    By lewis in forum Qt Tools
    Replies: 47
    Last Post: 2nd April 2007, 17:30
  5. Passing Object to dll
    By ankurjain in forum Qt Programming
    Replies: 2
    Last Post: 1st April 2006, 10:50

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.