pixel.h file:
#ifndef PIXEL_H
#define PIXEL_H
#include <QMainWindow>
namespace Ui {
class pixel;
}
class pixel : public QMainWindow
{
Q_OBJECT
public:
explicit pixel(QWidget *parent = 0);
~pixel();
private:
Ui::pixel *ui;
private slots:
void draw();
};
#endif // PIXEL_H
-----------------------------------------------------------------
pixel.cpp file:
#include "pixel.h"
#include "ui_pixel.h"
pixel::pixel(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::pixel)
{
ui->setupUi(this);
connect(this->ui->pushButton,SIGNAL(clicked()),this,SLOT(draw()));
//Function connects
}
pixel::~pixel()
{
delete ui;
}
void pixel::draw()
{
int x1,y1;
x1=this->ui->textEdit->toPlainText().toInt(); //x-coordinate
y1=this->ui->textEdit_2->toPlainText().toInt();//y-coordinate
QRgb value; // RGB value
value= qRgb(255,255,0);
QImage q(400,400,QImage::Format_RGB32);
q.setPixel(x1,y1,value);
this->ui->label_3->setPixmap(QPixmap::fromImage(q));
}
#ifndef PIXEL_H
#define PIXEL_H
#include <QMainWindow>
namespace Ui {
class pixel;
}
class pixel : public QMainWindow
{
Q_OBJECT
public:
explicit pixel(QWidget *parent = 0);
~pixel();
private:
Ui::pixel *ui;
private slots:
void draw();
};
#endif // PIXEL_H
-----------------------------------------------------------------
pixel.cpp file:
#include "pixel.h"
#include "ui_pixel.h"
pixel::pixel(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::pixel)
{
ui->setupUi(this);
connect(this->ui->pushButton,SIGNAL(clicked()),this,SLOT(draw()));
//Function connects
}
pixel::~pixel()
{
delete ui;
}
void pixel::draw()
{
int x1,y1;
x1=this->ui->textEdit->toPlainText().toInt(); //x-coordinate
y1=this->ui->textEdit_2->toPlainText().toInt();//y-coordinate
QRgb value; // RGB value
value= qRgb(255,255,0);
QImage q(400,400,QImage::Format_RGB32);
q.setPixel(x1,y1,value);
this->ui->label_3->setPixmap(QPixmap::fromImage(q));
}
Output
No comments:
Post a Comment