qt之點的繪製示例demo

萧海~發表於2024-05-21
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include<QPainter>

#include<QColor>


 QColor m_color;
 int m_x=0;
 int m_y=0;
 int m_w=0;
 int m_h=0;
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    // connect(&m_load,SIGNAL(draw_sig(uint32_t,uint32_t,uint32_t,uint32_t,QColor)),this,SLOT(set_params(uint32_t,uint32_t,uint32_t,uint32_t,QColor)));
    m_load.start();
}

MainWindow::~MainWindow()
{
    delete ui;
}



void MainWindow::paintEvent(QPaintEvent *event)
{
    QPainter painter(this);

    // // 繪製畫素點
    // painter.setPen(m_color);
    // painter.drawPoint(m_x, m_y);
    // qDebug()<<m_x<<m_y<<"+++++";
    // update();
    int startX=10;
    int startY=10;
    painter.setPen(QColor(255,0,0));
    for(int i=0;i<50;i++){
        for(int j=0;j<50;j++)
        {
            painter.drawPoint(startX+j,startY+i);
        }
    }
}

相關文章