[Qt-interest] Events
OS Prog
osprog at gmail.com
Sat May 1 13:17:01 CEST 2010
Hi,
>
> I'm trying to disable the mouse events to QWidget and its child widgets and
> to replace them with my custom event.
> I have event() function in my parent class and I'm receiving my custom
> events there. After decoding them I'm trying to prepare QMouseEvend and
> send
> it to the widgets, but their child widget doesn't receive it... I'm kind of
> lost with the events.
>
> I'll try to post some code later.
>
> Regards,
> Nikolay
>
> Hi,
That's what I'm trying
MainWidget::MainWidget(QWidget *parent, Qt::WFlags flags)
: QWidget(parent, flags)
{
calc = new CalcPage(); //inherits QFrame
}
bool MainWidget::event(QEvent *event)
{
switch (event->type())
{
case QTouchEvent::TouchBegin:
case QTouchEvent::TouchUpdate:
case QTouchEvent::TouchEnd:
{
QList<QTouchEvent::TouchPoint > touchPoints =
static_cast<QTouchEvent *>(event)->touchPoints();
if(touchPoints.size() > 0)
{
QMouseEvent *e;
switch(touchPoints.at(0).state())
{
case Qt::TouchPointMoved:
{
e = new
QMouseEvent(QEvent::MouseMove,QPoint(touchPoints.at(0).pos().x(),touchPoints.at(0).pos().y()),Qt::NoButton,Qt::NoButton,Qt::NoModifier);
break;
}
case Qt::TouchPointPressed:
{
e = new
QMouseEvent(QEvent::MouseButtonPress,QPoint(touchPoints.at(0).pos().x(),touchPoints.at(0).pos().y()),Qt::NoButton,Qt::NoButton,Qt::NoModifier);
break;
}
case Qt::TouchPointReleased:
default:
{
e = new
QMouseEvent(QEvent::MouseButtonRelease,QPoint(touchPoints.at(0).pos().x(),touchPoints.at(0).pos().y()),Qt::NoButton,Qt::NoButton,Qt::NoModifier);
break;
}
}
QApplication::postEvent(calc, e);
return true;
}
}
default:
break;
}
return QWidget::event(event);
}
I have QTouchEvents coming to this widget and I want to make a QMouseEvent
and send it to the 'calc' instance.
The 'CalcPage' has QPushButtons on it, but it looks they never received the
events I'm sending.
Regards,
Nikolay
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100501/a167a8e9/attachment.html
More information about the Qt-interest-old
mailing list