1 Attachment(s)
Error when promoting a custom widget
hello,
i wrote a class that handles simple drawing actions
here is the header file
Code:
#ifndef PARENT_LINE
#define PARENT_LINE
#include <QFrame>
#include <QPainter>
#include <QMouseEvent>
class parentLine
: public QFrame{
Q_OBJECT
public:
parentLine
(QWidget *parent
= 0, Qt
::WFlags flags
= 0);
~parentLine();
protected:
bool isDrawing;
};
#endif
and cpp
Code:
#include "parentLine.h"
parentLine
::parentLine(QWidget *parent, Qt
::WFlags flags
){
setMouseTracking(true);
isDrawing = false;
}
parentLine::~parentLine(){}
if(isDrawing){
int x1 = tmpFirstPoint->x();
int y1 = tmpFirstPoint->y();
int x2 = event->pos().x();
int y2 = event->pos().y();
painter.drawLine(x1,y1,x2+5,y2+5);
isDrawing = true;
}
}
{
isDrawing = true;
tmpFirstPoint
= new QPoint(event
->pos
().
x(),event
->pos
().
y());
}
{
isDrawing = false;
tmpFirstPoint = 0;
}
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? :eek:
Attachment 751
Re: Error when promoting a custom widget
Sounds like you first attempted to promote a plain QWidget to "parentLine" and now when trying to fix the situation as the correct base class is QFrame, Designer thinks that this is something inappropriate. I'm not sure if there is any other way around than restarting the Designer...