platform: linux, QT4.6.3
Hi All,
I want to simulate the mouse left click event
here is code snippets.
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QMouseEvent>
#include <QGraphicsScene>
#include <QGraphicsView>
#include <QDebug>
MainWindow
::MainWindow(QWidget *parent
) : ui(new Ui::MainWindow)
{
ui->setupUi(this);
view_->setScene(scene_);
}
MainWindow::~MainWindow()
{
delete ui;
}
{
if(event->button() == Qt::RightButton)
{
qDebug()<<"right";
}
else
{
qApp->postEvent(view_,event); //will crash here
}
}
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QMouseEvent>
#include <QGraphicsScene>
#include <QGraphicsView>
#include <QDebug>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
scene_ = new QGraphicsScene(0,0, 480, 800,this);
view_ = new QGraphicsView(this);
view_->setScene(scene_);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::mousePressEvent(QMouseEvent *event)
{
if(event->button() == Qt::RightButton)
{
qDebug()<<"right";
}
else
{
qApp->postEvent(view_,event); //will crash here
}
}
To copy to clipboard, switch view to plain text mode
when click left button on window, I want forward it to QGraphicsScene (I don't want to use the event filter). but when I click the left button,the app crashed,I was wondering why
Thanks advance for your help.
Best regards,
hb
Bookmarks