QT中出现:error: variable `QPainter painter' has initializer but incomplete type
#include "picture.h"
#include "ui_picture.h"
#include"qpainter.h" //一开始在我自己的.cpp中没有加上这个声明,出现了那个错误,加上即可
picture::picture(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::picture)
{
ui->setupUi(this);
}
void picture::draw()
{
QPainter painter (this );
//painter.setPen( QPen( black, 8, DashDotLine) );
//painter.setBrush( QBrush( red, Dense6Pattern) );
//painter.drawEllipse( 20, 20, 100, 60 );
painter
}
picture::~picture()
{
delete ui;
}