Hi,
I'm trying to make a program where you choose a texture, and size, and it will draw a grid. I've got this part working to an extent using QGraphicsScene & a GraphicsView.
void MainWindow::on_btnDrawGrid_clicked()
{
ui->graphicsView->setScene(scene);
int height = ui->graphicsView->height();
int height2 = height / ui->txtGridX->text().toInt();
int length = ui->graphicsView->width();
int length2 = length / ui->txtGridY->text().toInt();
for (int x=0; x<=height; x+=height2)
scene
->addLine
(x,
0,x,height,
QPen(Qt
::red));
for (int y=0; y<=length; y+=length2)
scene
->addLine
(0,y,length,y,
QPen(Qt
::red));
ui->graphicsView->fitInView(scene->itemsBoundingRect());
}
void MainWindow::on_btnDrawGrid_clicked()
{
QGraphicsScene* scene = new QGraphicsScene;
ui->graphicsView->setScene(scene);
int height = ui->graphicsView->height();
int height2 = height / ui->txtGridX->text().toInt();
int length = ui->graphicsView->width();
int length2 = length / ui->txtGridY->text().toInt();
for (int x=0; x<=height; x+=height2)
scene->addLine(x,0,x,height, QPen(Qt::red));
for (int y=0; y<=length; y+=length2)
scene->addLine(0,y,length,y, QPen(Qt::red));
ui->graphicsView->fitInView(scene->itemsBoundingRect());
}
To copy to clipboard, switch view to plain text mode
The next part is what I am stuck on. I want to drag and drop images onto the grid, move them around etc. Then, when I press save I need it to interpret the grid with images, and draw a PNG file with different colours representing the different bits of the grid, texture etc.
Any help and/or guidance would be much appreciated.
Regards,
Richard
Bookmarks