title: Qt Artificial mouse clicks doesnt work properly
body: <p>Small toy app can be found here: <a href="http://gist.github.com/517445" rel="nofollow noreferrer">http://gist.github.com/517445</a></p>
  
  <p>I am trying to send artificial mouse event to widget and I use <strong><em>QApplication::sendEvent</em></strong> for that, next I check ev.isAccepted() and it returns False, even worse! Widget I've sent event to doesnt handle it (it is calendar widged and no date is picked) and I am in doubt that it even receives it, because I can see how mouseEventPressed is fired up on parent widget. </p>
  
  <p>Qt Code:</p>
  
  <pre><code>#include "calendar.h"
  
  Calendar::Calendar(QWidget *parent) :
      QWidget(parent)
  {
      qCal = new QCalendarWidget;
      qBtn = new QPushButton(tr("Press me"));
  
      connect(qBtn, SIGNAL(clicked()), this, SLOT(testCustomClick()));
  
      QVBoxLayout *layout = new QVBoxLayout;
      layout-&gt;addWidget(qCal);
      layout-&gt;addWidget(qBtn);
  
      setLayout(layout);
      qDebug() &lt;&lt; "Date:" &lt;&lt; QDate::currentDate();
   }
  
   Calendar::~Calendar()
   {
   }
  
  void Calendar::testCustomClick()
  {
      QMouseEvent qm2(QEvent::MouseButtonPress, QPoint(qCal-&gt;width()/2,
           qCal-&gt;height()/2), Qt::LeftButton , Qt::LeftButton, Qt::NoModifier);
      QApplication::sendEvent(qCal, &amp;qm2);
  
      //this one is always False
      qDebug() &lt;&lt; "isAccepted: " &lt;&lt; qm2.isAccepted();
  }
  
  
  void Calendar::mousePressEvent(QMouseEvent* ev)
  {
      //this is executed even for QMouseEvent which sended to qCal =((
      //if we click on qCal with real mouse it is not executed
      qDebug() &lt;&lt; "mouse event: " &lt;&lt; ev &lt;&lt; "x=" &lt;&lt; ev-&gt;x() &lt;&lt;" y=" &lt;&lt; ev-&gt;y();
      QWidget::mousePressEvent(ev);
  }
  </code></pre>
  
  <p>According to source code <strong>QApplication::sendEvent</strong> calls <strong>widget->event()</strong> which for QCalendarWidget is ended up in <em>QAbstractScrollArea</em> which returns false for every mouse related event.</p>
  
  <p>If I am right, then how can I emulate mouse clicks and keypresses?</p>