本文整理汇总了C++中QTouchEvent::widget方法的典型用法代码示例。如果您正苦于以下问题:C++ QTouchEvent::widget方法的具体用法?C++ QTouchEvent::widget怎么用?C++ QTouchEvent::widget使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTouchEvent
的用法示例。
在下文中一共展示了QTouchEvent::widget方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sipConvertFromType
static PyObject *meth_QTouchEvent_widget(PyObject *sipSelf, PyObject *sipArgs)
{
PyObject *sipParseErr = NULL;
{
QTouchEvent *sipCpp;
if (sipParseArgs(&sipParseErr, sipArgs, "B", &sipSelf, sipType_QTouchEvent, &sipCpp))
{
QWidget *sipRes;
Py_BEGIN_ALLOW_THREADS
sipRes = sipCpp->widget();
Py_END_ALLOW_THREADS
return sipConvertFromType(sipRes,sipType_QWidget,NULL);
}
}
示例2: notify
bool MixxxApplication::notify(QObject* target, QEvent* event) {
switch (event->type()) {
case QEvent::TouchBegin:
case QEvent::TouchUpdate:
case QEvent::TouchEnd:
{
QTouchEvent* touchEvent = static_cast<QTouchEvent*>(event);
QList<QTouchEvent::TouchPoint> touchPoints = touchEvent->touchPoints();
QEvent::Type eventType = QEvent::None;
Qt::MouseButtons buttons = Qt::NoButton;
QWidget* fakeMouseWidget = NULL;
bool baseReturn;
//qDebug() << "&" << touchEvent->type() << target;
if (touchEvent->deviceType() != QTouchEvent::TouchScreen) {
break;
}
switch (event->type()) {
case QEvent::TouchBegin:
// try to deliver as touch event
baseReturn = QApplication::notify(target, event);
if (dynamic_cast<MixxxMainWindow*>(touchEvent->widget())) {
// the touchEvent has fallen trough to the MixxxMainWindow, because there
// was no touch enabled widget found.
// Now we resent this event and all following events for this touch point
// as Mouse events.
eventType = QEvent::MouseButtonPress;
if (touchIsRightButton()) {
// touch is right click
m_activeTouchButton = Qt::RightButton;
buttons = Qt::RightButton;
} else {
m_activeTouchButton = Qt::LeftButton;
buttons = Qt::LeftButton;
}
m_fakeMouseSourcePointId = touchPoints.first().id();
m_fakeMouseWidget = dynamic_cast<QWidget*>(target);
fakeMouseWidget = m_fakeMouseWidget;
break;
}
return baseReturn;
case QEvent::TouchUpdate:
if (m_fakeMouseWidget) {
eventType = QEvent::MouseMove;
buttons = m_activeTouchButton;
fakeMouseWidget = m_fakeMouseWidget;
break;
}
return QApplication::notify(target, event);
case QEvent::TouchEnd:
if (m_fakeMouseWidget) {
eventType = QEvent::MouseButtonRelease;
m_fakeMouseSourcePointId = touchPoints.first().id();
fakeMouseWidget = m_fakeMouseWidget;
m_fakeMouseWidget = NULL;
break;
}
return QApplication::notify(target, event);
default:
return QApplication::notify(target, event);
}
for (int i = 0; i < touchPoints.count(); ++i) {
const QTouchEvent::TouchPoint& touchPoint = touchPoints.at(i);
if (touchPoint.id() == m_fakeMouseSourcePointId) {
QMouseEvent mouseEvent(eventType,
fakeMouseWidget->mapFromGlobal(touchPoint.screenPos().toPoint()),
touchPoint.screenPos().toPoint(),
m_activeTouchButton, // Button that causes the event
buttons,
touchEvent->modifiers());
//qDebug() << "#" << mouseEvent.type() << mouseEvent.button() << mouseEvent.buttons() << mouseEvent.pos() << mouseEvent.globalPos();
//if (m_fakeMouseWidget->focusPolicy() & Qt::ClickFocus) {
// fakeMouseWidget->setFocus();
//}
QApplication::notify(fakeMouseWidget, &mouseEvent);
return true;
}
}
//qDebug() << "return false";
return false;
break;
}
case QEvent::MouseButtonRelease:
{
bool ret = QApplication::notify(target, event);
if (m_fakeMouseWidget) {
// It may happen the faked mouse event was grabbed by a non touch window.
// eg.: if we have started to drag by touch.
// In this case X11 generates a MouseButtonRelease instead of a TouchPointReleased Event.
// QApplication still tracks the Touch point and prevent touch to other widgets
// So we need to fake the Touch release event as well to clean up
// QApplicationPrivate::widgetForTouchPointId and QApplicationPrivate::appCurrentTouchPoints;
m_fakeMouseWidget = NULL; // Disable MouseButtonRelease fake
QList<QTouchEvent::TouchPoint> touchPoints;
QTouchEvent::TouchPoint tp;
//.........这里部分代码省略.........