mylabel.h
#ifndef MYLABEL_H
#define MYLABEL_H
#include <QLabel>
{
Q_OBJECT
public:
void setDrawflag(bool a);
protected:
private:
bool drawflag;
};
#endif
#ifndef MYLABEL_H
#define MYLABEL_H
#include <QLabel>
class MyLabel : public QLabel
{
Q_OBJECT
public:
MyLabel(QWidget *);
void setDrawflag(bool a);
protected:
void paintEvent ( QPaintEvent * event );
private:
bool drawflag;
};
#endif
To copy to clipboard, switch view to plain text mode
mylabel.cpp
#include"MyLabel.h"
#include <QPainter>
#include <QLabel>
{
}
{
if(drawflag==true)
{
setAutoFillBackground(true);
painter.setPen(Qt::blue);
painter.drawLine(0,0,401,331);
}
}
void MyLabel::setDrawflag(bool a)
{
drawflag=a;
}
#include"MyLabel.h"
#include <QPainter>
#include <QLabel>
MyLabel::MyLabel(QWidget *parent)
: QLabel(parent)
{
}
void MyLabel::paintEvent(QPaintEvent *event)
{
QPainter painter(this);
if(drawflag==true)
{
QPainter painter(this);
setBackgroundRole(QPalette::Dark);
setAutoFillBackground(true);
painter.setPen(Qt::blue);
painter.drawLine(0,0,401,331);
}
}
void MyLabel::setDrawflag(bool a)
{
drawflag=a;
}
To copy to clipboard, switch view to plain text mode
Bookmarks