我是新的qt c ++。我想绘制一个三角形。但我面临太多错误。 它不会重新识别poly和qpoint以及* e 帮帮我PLZ
#include "dialog.h"
#include "ui_dialog.h"
#include <QtCore>
#include <QtGui>
#include <QGraphicsScene>
#include <QGraphicsEllipseItem>
#include<qpainter.h>
#include<QPolygon>
#include<QPoint>
#include<QPainter>
#include<QPaintEvent>
Dialog::Dialog(int a1,int b1,int a2,int b2,int a3,int b3,char t,QWidget *parent):
QDialog(parent),
ui(new Ui::Dialog),
x1(a1),x2(a2),x3(a3),y1(b1),y2(b2),y3(b3),type(t)
{
ui->setupUi(this);
scene = new QGraphicsScene(this);
scene = new QGraphicsScene(this);
ui->graphicsView->setScene(scene);
QBrush redBrush (Qt::red);
QPen blackpen(Qt::black);
blackpen.setWidth(1);
if(type=='c')
ellipse = scene->addEllipse(0,0,10,10,blackpen,redBrush);
else if(type=='l')
{
//draw line
}
else
{
//draw traingle
paintEvent(QPaintEvent *e);
错误:在此scop中未声明'e' }
}
void Dialog::paintEvent(QPaintEvent *e)
{
QPainter painter(this);
QPolygon poly;
poly «QPoint(100,150);
错误:在程序中迷路'\ 302' poly«; QPoint(120,130); ^ poly«QPoint(90,130); poly«QPoint(120,130);
QPen linepen;
linepen.setWidth(8);
linepen.setColor(Qt::red);
linepen.setJoinStyle(Qt::MiterJoin);
painter.setPen(linepen);
QBrush fillbrush;
fillbrush.setColor(Qt::red);
fillbrush.setStyle(Qt::SolidPattern);
QPainterPath path;
path.addPolygon(poly);
painter.drawPolygon(poly);
painter.fillPath(path,fillbrush);}
Dialog::~Dialog(){
delete ui;
}