QT 图形的绘制
作者:互联网
QT添加label的属性:
QLabel* lb1=new QLabel(this);
lb1->setStyleSheet("color:blue");
lb1->setText(getDex(ui->m_pb1,ui->m_pb2));
lb1->move(ui->m_pb1->pos().x()+(ui->m_pb2->pos().x()-ui->m_pb1->pos().x())/2+1,ui->m_pb1->pos().y()+(ui->m_pb2->pos().y()-ui->m_pb1->pos().y())/2+1);
QT画线:
QPainter paint(this);
paint.drawPixmap(0,0,WIN_WIGHT,WIN_HEIGHT,Pix);
QColor balck(0,0,0);
QPen pen(balck);
pen.setWidth(2);
paint.setPen(pen);
QPoint point1(ui->m_pb1->pos().x()+ui->m_pb1->width()/2,ui->m_pb1->pos().y()+ui->m_pb1->height()/2);
QPoint point2(ui->m_pb2->pos().x()+ui->m_pb2->width()/2,ui->m_pb2->pos().y()+ui->m_pb2->height()/2);
paint.drawLine(point1,point2);
QT定时器的使用:
1.定时器的声明:
2.定时器和函数绑定:
timer=new QTimer(this);
connect(timer,SIGNAL(timeout()),this,SLOT(ppt()));
3.定时器的开始:
timer2->start(50); //计时器开始
标签:lb1,pb1,QT,pb2,pos,paint,ui,图形,绘制 来源: https://blog.csdn.net/qq_41617848/article/details/94460716