MainWindow
::MainWindow(QWidget *parent
) : ui(new Ui::MainWindow)
{
ui->setupUi(this);
ui->graphicsView->setScene(scene);
scene->installEventFilter(this);
//In the Switch cases Im calling for Mouse press, move and release events. Then update() func in move and release cases. The same graphicview co-ordinates are stored in Static variable, accesed same in the Paintevent.
{
qDebug("Entering the paint");
QPen myPen
(Qt
::blue,
3,Qt
::SolidLine);
painter.setPen(myPen);
QRectF r1
(s_count_x,s_count_y,
(s_count_x1
-s_count_x
),
(s_count_y1
-s_count_y
));
scene->addRect(r1,myPen);
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
scene=new QGraphicsScene(0,0,740,400);
ui->graphicsView->setScene(scene);
scene->installEventFilter(this);
bool MainWindow::eventFilter(QObject* obj, QEvent* e )
//In the Switch cases Im calling for Mouse press, move and release events. Then update() func in move and release cases. The same graphicview co-ordinates are stored in Static variable, accesed same in the Paintevent.
void MainWindow::paintEvent(QPaintEvent *e)
{
qDebug("Entering the paint");
QPainter painter(this);
QPen myPen(Qt::blue, 3,Qt::SolidLine);
painter.setPen(myPen);
QRectF r1(s_count_x,s_count_y,(s_count_x1-s_count_x),(s_count_y1-s_count_y));
scene->addRect(r1,myPen);
To copy to clipboard, switch view to plain text mode
Bookmarks