qt之点的绘制示例demo

#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);
        }
    }
}

posted @ 2024-05-21 16:53  萧海~  阅读(64)  评论(0编辑  收藏  举报