QT画线(记录一下)

#include "mainwindow.h"
#include "ui_mainwindow.h"
#include 
#include 
 
  
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    //ui->pushButton->resize(width(),height());
    qDebug()<pushButton->pos().x();
}
MainWindow::~MainWindow()
{
    delete ui;
}
void MainWindow::paintEvent(QPaintEvent *)
{
    QPainter painter(this);
    QPen pen(QColor(255,0,0));
    painter.setPen(pen);
    QVectordata1{{100,100},{100,200},{300,200},{300,400}} ;
    for (int i = 1; i < data1.count(); ++i)
    {
        //painter.drawLine(data1.at(i - 1), data1.at(i));
        painter.drawLine(data1[i-1],data1[i]);
    }

你可能感兴趣的:(qt,ui,开发语言)