Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void MainWindow::mousePressEvent(QMouseEvent *e)
- {
- if (e->button()==Qt::LeftButton)
- {
- selectionStarted=true;
- selectionRect.setTopLeft(e->pos());
- selectionRect.setBottomRight(e->pos());
- rb->setGeometry(selectionRect);
- rb->show();
- }
- }
- void MainWindow::mouseMoveEvent(QMouseEvent *e)
- {
- if (selectionStarted)
- {
- selectionRect.setBottomRight(e->pos());
- rb->setGeometry(selectionRect);
- rb->show();
- repaint();
- }
- }
- void MainWindow::mouseReleaseEvent(QMouseEvent *e)
- {
- selectionStarted=false;
- }
- void MainWindow::on_pushButton_8_clicked()
- {
- if(selectionRect.width() > 5 && selectionRect.height() > 5 && !rb->isHidden()){
- QPoint start = ui->edit_label->mapFromGlobal(selectionRect.topLeft());
- int h = (ui->edit_label->rect().height() - ui->edit_label->pixmap()->rect().height())/2 - 23, w = (ui->edit_label->rect().width() - ui->edit_label->pixmap()->rect().width())/2;
- ui->edit_label->setPixmap(ui->edit_label->pixmap()->copy(start.x() - w, start.y() - h, selectionRect.width(),selectionRect.height()));
- ui->edit_label->show();
- fileName = "C:/Users/Youssef Yossry/Desktop/3rd Year-First Term/HCI/PRO/workspace/current";
- angle=0;
- QFile file(fileName);
- file.open(QIODevice::WriteOnly);
- ui->edit_label->pixmap()->save(&file, "PNG");
- add_to_undo(*ui->edit_label->pixmap(), angle);
- redo.clear();
- redoAngle.clear();
- rb->hide();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement