Results 1 to 2 of 2

Thread: Error when promoting a custom widget

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2006
    Posts
    1
    Thanks
    1
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Error when promoting a custom widget

    hello,
    i wrote a class that handles simple drawing actions

    here is the header file
    Qt Code:
    1. #ifndef PARENT_LINE
    2. #define PARENT_LINE
    3.  
    4. #include <QFrame>
    5. #include <QPainter>
    6. #include <QMouseEvent>
    7.  
    8. class parentLine : public QFrame
    9. {
    10. Q_OBJECT
    11.  
    12. public:
    13. parentLine(QWidget *parent = 0, Qt::WFlags flags = 0);
    14. ~parentLine();
    15.  
    16. protected:
    17. QPoint * tmpFirstPoint;
    18. bool isDrawing;
    19.  
    20. void mouseMoveEvent(QMouseEvent *event);
    21. void mousePressEvent(QMouseEvent *event);
    22. void mouseReleaseEvent(QMouseEvent *event);
    23. };
    24. #endif
    To copy to clipboard, switch view to plain text mode 

    and cpp
    Qt Code:
    1. #include "parentLine.h"
    2.  
    3. parentLine::parentLine(QWidget *parent, Qt::WFlags flags)
    4. : QFrame(parent, flags)
    5. {
    6. setMouseTracking(true);
    7. isDrawing = false;
    8. QPoint *tmpFirstPoint = new QPoint(0,0);
    9. }
    10.  
    11. parentLine::~parentLine(){}
    12.  
    13. void parentLine::mouseMoveEvent(QMouseEvent *event){
    14. if(isDrawing){
    15. QPainter painter(this);
    16. int x1 = tmpFirstPoint->x();
    17. int y1 = tmpFirstPoint->y();
    18. int x2 = event->pos().x();
    19. int y2 = event->pos().y();
    20. painter.drawLine(x1,y1,x2+5,y2+5);
    21. isDrawing = true;
    22. }
    23. }
    24.  
    25. void parentLine::mousePressEvent(QMouseEvent *event)
    26. {
    27. isDrawing = true;
    28. tmpFirstPoint = new QPoint(event->pos().x(),event->pos().y());
    29. }
    30.  
    31. void parentLine::mouseReleaseEvent(QMouseEvent *event)
    32. {
    33. isDrawing = false;
    34. tmpFirstPoint = 0;
    35. }
    To copy to clipboard, switch view to plain text mode 

    when i try to promote this class to any widget the designer warns as "parentLine cannot be used as the class of the promoted widget, as a class of that name already exists and extends QWidget"
    what i'm doing wrong?

    promote-problem.jpg
    Last edited by engin; 15th December 2006 at 15:54. Reason: updated contents

Similar Threads

  1. Replies: 1
    Last Post: 5th November 2006, 23:50
  2. Problem applying setWindowOpacity to a custom Widget
    By yellowmat in forum Qt Programming
    Replies: 8
    Last Post: 1st November 2006, 10:05
  3. Custom Widget Plugin Analog Clock
    By kemp in forum Qt Programming
    Replies: 8
    Last Post: 11th August 2006, 13:22
  4. Replies: 3
    Last Post: 12th April 2006, 08:20
  5. Replies: 4
    Last Post: 24th March 2006, 22: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.