I'm trying to trigger fake click events on QPushButtons.
ButtonsMap::ButtonsMap()
{
m_b1 = new QPushButton("push me 1", this);
m_b2 = new QPushButton("push me 2", this);
m_b3 = new QPushButton("push me 3", this);
m_b1->move(0,0);
m_b2->move(0,40);
m_b3->move(0,80);
connect(m_b1, SIGNAL(clicked()), this, SLOT(setclicked1()));
connect(m_b2, SIGNAL(clicked()), this, SLOT(setclicked2()));
connect(m_b3, SIGNAL(clicked()), this, SLOT(setclicked3()));
}
And then I use this slot to triggers them using a custum TouchEvent class (not QTouchEvent, something from scratch)
void TouchToMouse::NewTouchEvent(const TouchEvent& e ) {
...
QWidget *target = clickTarget(m_mw, pos);
switch (e.m_type) {
case APPEAR:
event = new QMouseEvent(QEvent::MouseButtonPress, pos, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
break;
case MOVE:
event = new QMouseEvent(QEvent::MouseMove, pos, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
break;
case DISAPPEAR:
event = new QMouseEvent(QEvent::MouseButtonRelease, pos, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
break;
}
QApplication::postEvent(target, event);*
}
My problem is: it works, but only for the first button m_b1
, even though QWidget *target
points to the right widget (I checked the adresses). It seems like m_b2
and m_b3
never do receive those events. Any idea on what might be going wrong?