void pWidget::paintEvent(QPaintEvent *){ QPainter painter(this); //创建QPainter一个对象 QPen pen; pen.setColor(Qt::black);//设置画笔为蓝色 painter.setPen(pen); // painter.drawRect(10,10,120,200);//绘制矩形 painter.setRenderHint(QPainter::Antialiasing, true); painter.setPen(QPen(Qt::black, 12, Qt::DashDotLine, Qt::RoundCap)); painter.setBrush(QBrush(Qt::green, Qt::SolidPattern)); // painter.drawEllipse(150,10, 400, 200);//绘制椭圆 painter.setPen(Qt::red); //for(int i=0;i<=200;i ) // { // painter.drawPoint(i,140);//由点拼成线条 // } //painter.drawLine(20,20,150,310);//两点划线 /*for(int x=0;x<=700;x=x 5) { y1=y2; y2=rand()%400; painter.drawLine(x-5,y1,x,y2); } stack<int> p; p.push(32); p.push(4); cout<<p.top();*/ for(int m=1;m<2;m ) { int x=0; // painter.eraseRect(0,0,800,600); listOne.push_front(rand()%300); listOne.push_front(rand()%300);i=listOne.begin(); //temp1=*i;for(i=listOne.begin();i!=listOne.end(); i=i.operator (1)) { j=i.operator (1); temp2=*j; painter.drawLine(x,temp1,x 20,temp2); cout<<temp1<<" "<<temp2<<endl; temp1=temp2; x=x 20; } //此段用数组中数据的来画图Sleep(1000);update(); }
评论