Results 1 to 3 of 3

Thread: error: invalid use of incomplete type 'struct QPaint

  1. #1
    Join Date
    May 2012
    Posts
    57
    Thanks
    11
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default error: invalid use of incomplete type 'struct QPaint

    Hello, I'm trying to implement a simple class to draw things:
    Draw.h:
    Qt Code:
    1. #ifndef DRAW_H
    2. #define DRAW_H
    3. #include <QWidget>
    4. //------------------------------------
    5. class Canvas : public QWidget
    6. {
    7. Q_OBJECT
    8. public:
    9. Canvas(QWidget *parent = 0);
    10. protected:
    11. void paintEvent(QPaintEvent *e);
    12. private:
    13. QImage image;
    14. };
    15. #endif // DRAW_H
    To copy to clipboard, switch view to plain text mode 
    Draw.cpp:
    Qt Code:
    1. #include <QPainter>
    2. #include "draw.h"
    3. //-------------------------------------------
    4. Canvas::Canvas(QWidget *parent) : QWidget(parent)
    5. {
    6. }
    7. //-------------------------------------------
    8. void Canvas::paintEvent(QPaintEvent *e)
    9. {
    10. QPainter p(this);
    11. QRect r = e->rect(); // error: invalid use of incomplete type 'struct QPaintEvent'
    12. p.drawImage(r, image, r);
    13. }
    To copy to clipboard, switch view to plain text mode 

    I don't understand this error. Incomplete type??
    What am I doing wrong?

    Thank you.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: error: invalid use of incomplete type 'struct QPaint

    Add this:
    Qt Code:
    1. #include <QPaintEvent>
    To copy to clipboard, switch view to plain text mode 
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


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

    Cremers (13th October 2012)

  4. #3
    Join Date
    May 2012
    Posts
    57
    Thanks
    11
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: error: invalid use of incomplete type 'struct QPaint

    Duh. Thank you.

  5. The following user says thank you to Cremers for this useful post:


Similar Threads

  1. invalid use of incomplete type 'struct MSG'
    By libed in forum Qt Programming
    Replies: 5
    Last Post: 21st February 2019, 12:32
  2. error: invalid use of incomplete type 'struct QMetaEnum'
    By dyngoman in forum Qt Programming
    Replies: 3
    Last Post: 12th March 2010, 13:38
  3. Replies: 4
    Last Post: 12th October 2009, 19:36
  4. Replies: 1
    Last Post: 15th October 2007, 14:21
  5. Replies: 5
    Last Post: 28th September 2007, 10:23

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.