platform: linux, QT4.6.3

Hi All,

I want to simulate the mouse left click event
here is code snippets.

Qt Code:
  1. #include "mainwindow.h"
  2. #include "ui_mainwindow.h"
  3. #include <QMouseEvent>
  4. #include <QGraphicsScene>
  5. #include <QGraphicsView>
  6. #include <QDebug>
  7.  
  8. MainWindow::MainWindow(QWidget *parent) :
  9. QMainWindow(parent),
  10. ui(new Ui::MainWindow)
  11. {
  12. ui->setupUi(this);
  13. scene_ = new QGraphicsScene(0,0, 480, 800,this);
  14. view_ = new QGraphicsView(this);
  15. view_->setScene(scene_);
  16.  
  17.  
  18. }
  19.  
  20. MainWindow::~MainWindow()
  21. {
  22. delete ui;
  23. }
  24.  
  25. void MainWindow::mousePressEvent(QMouseEvent *event)
  26. {
  27. if(event->button() == Qt::RightButton)
  28. {
  29. qDebug()<<"right";
  30. }
  31. else
  32. {
  33. qApp->postEvent(view_,event); //will crash here
  34. }
  35. }
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