I created plugin which draws cross on parent widget. In constructor:
mAim=new HmiAim(this->parentWidget());
mAim=new HmiAim(this->parentWidget());
To copy to clipboard, switch view to plain text mode
In header(description of class):
...
HmiAim *mAim;
}
{
Q_OBJECT
protected:
};
HmiAim *mAim;
}
class HmiAim:public QWidget
{
Q_OBJECT
protected:
virtual void paintEvent(QPaintEvent *event);
};
To copy to clipboard, switch view to plain text mode
And paint event:
void
{
pen.
setColor(QColor (225,
104,
15));
pen.setWidth(2);
painter.setPen(pen);
painter.drawLine(0,15,30, 15);
painter.drawLine(15,0, 15, 30);
}
void
HmiAim::paintEvent(QPaintEvent *event)
{
QPainter painter(this);
QPen pen;
pen.setColor(QColor (225,104,15));
pen.setWidth(2);
painter.setPen(pen);
painter.drawLine(0,15,30, 15);
painter.drawLine(15,0, 15, 30);
}
To copy to clipboard, switch view to plain text mode
It works everywhere ,exept designer(works in preview,in projects). It even works in designer if I save UI-file with this plugin and open it - cross will be and in designer mode for saved plagins, but not for new added.
Bookmarks