#include "dialog.h" #include "ui_dialog.h" #include Dialog::Dialog(QWidget *parent) : QDialog(parent), ui(new Ui::Dialog) { ui->setupUi(this); n=0;shift=0; } Dialog::~Dialog() { delete ui; } void Dialog::up() { int tmp=this->height(); for(int i=0;itmp) tmp=py[i]; if(tmp>this->height()-10) return; for(int i=0;iwidth(); for(int i=0;itmp) tmp=px[i]; if(tmp>this->width()-10) return; for(int i=0;ipos().x(),y=e->pos().y(); if(e->button()==Qt::RightButton) { int sel=-1; for(int i=0;i=0&&shift==0&&stat[sel]) for(int i=0;i=10&&y>=10&&x<=this->width()-10&&y<=this->height()-10) { n++; stat.append(0); px.append(x); py.append(y); } } update(); } void Dialog::del() { for(int i=0;ikey()) { case Qt::Key_Up: up(); break; case Qt::Key_Down: down(); break; case Qt::Key_Left: left(); break; case Qt::Key_Right: right(); break; case Qt::Key_Backspace: case Qt::Key_Delete: del(); break; case Qt::Key_Shift: shift=1; break; } } void Dialog::keyReleaseEvent(QKeyEvent *e) { if(e->key()==Qt::Key_Shift) shift=0; }