////Form2.h
#include <qbutton.h>
class QPainter;
class Form2 : public QButton
{
Q_OBJECT
public:
Form2( QWidget* parent = 0, const char* name = 0,WFlags f = 0 );
~Form2();
protected:
void drawButton(QPainter * painter);
};
//form2.cpp
Form2::Form2( QWidget* parent, const char* name,WFlags f)
: QButton( parent, name,f)
{
}
Form2::~Form2()
{
// no need to delete child widgets, Qt does it all for us
}
void Form2::drawButton( QPainter *painter)
{
//QPainter painter(this);
painter->setPen(QPen(Qt::black, 3, Qt::DashDotLine));
painter->setBrush(QBrush(Qt::red, Qt::SolidPattern));
painter->drawEllipse(20, 20, 100, 60);
QButton::drawButton ( painter );
}
大家帮忙看看啊,我想 画一个圆形的按钮,但是不是我想要的结果。
下图式运行的效果