Results 1 to 10 of 10

Thread: QPainter

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2007
    Posts
    16
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QPainter

    Hello,

    I'm trying to display a line with QPainter with following code:
    drawit.h:
    Qt Code:
    1. #ifndef DRAWIT_H
    2. #define DRAWIT_H
    3. #include <QWidget>
    4. class DrawIt : public QWidget
    5. {
    6. Q_OBJECT
    7. public:
    8. DrawIt(QWidget *parent = 0);
    9. protected:
    10. QPainter *paint;
    11. };
    12. #endif
    To copy to clipboard, switch view to plain text mode 

    drawit.cpp:
    Qt Code:
    1. #include <QtGui>
    2. #include "drawit.h"
    3. DrawIt::DrawIt(QWidget *parent) : QWidget(parent)
    4. {
    5. paint = new QPainter();
    6. }
    7. void DrawIt::paintEvent(QPaintEvent *)
    8. {
    9. paint->drawLine(10, 10, 50, 50);
    10. }
    To copy to clipboard, switch view to plain text mode 

    main.cpp:
    Qt Code:
    1. #include <QApplication>
    2. #include "drawit.h"
    3. int main(int argc, char* argv[])
    4. {
    5. QApplication app(argc, argv);
    6. DrawIt *drawIt = new DrawIt;
    7. drawIt->show();
    8. return app.exec();
    9. }
    To copy to clipboard, switch view to plain text mode 

    This gives the error "no 'void DrawIt:aintEvent(QPaintEvent *)' member function declared in class DrawIt

    Where am i making the mistake?

    Thx in advance,
    Misko
    Last edited by jacek; 29th July 2007 at 20:08. Reason: missing [code] tags

Similar Threads

  1. [qt4,win,g++] QPainter on a QGLWidget
    By jh in forum Qt Programming
    Replies: 4
    Last Post: 28th July 2008, 06:29
  2. QPainter and QImage
    By beerkg in forum Newbie
    Replies: 3
    Last Post: 7th September 2006, 14:48
  3. QPainter in console apps?
    By Funklord in forum Qt Programming
    Replies: 2
    Last Post: 18th April 2006, 14:03
  4. Replies: 7
    Last Post: 20th March 2006, 20:03
  5. Replies: 12
    Last Post: 5th February 2006, 10:34

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
  •  
Qt is a trademark of The Qt Company.