TabletEvents是鼠標事件。Qt 4.8。 Mac OS上的平板電腦事件10.6.8
MAC OS Qt 4.8.0 - 4.8.5的實際值。 在任何操作系統上的Qt 4.7.3以及Windows和Linux上的Qt 4.8.0都可以正常工作。
我有兩個QGraphcisScene實例和兩個QGraphicsView實例。 相同的類型,但一個視圖有父母,另一個 - 不(它也是透明的,用於在桌面上繪畫)。
我正在使用平板電腦(wacom鋼筆和觸摸)進行繪畫。我處理QTabletEvents,它僅適用於沒有父級(意味着父母== 0)的QGrahicsView實例。
在具有父視圖(
QMainWindow-> centralWidget-> ControlContainerWidget-> QStackedLayout->的QGraphicsView
)片劑事件不自帶。他們來到QApplication::eventFilter
罰款,但不來看。他們來到QMainWindow
作爲mouseEvents
。 如果我將父項設置爲0,則平板電腦事件可以正常工作。
平板事件的第一個接收者是QMainWindow。 我看到裏面qt_mac_handleTabletEvent
:
QWidget *qwidget = [theView qt_qwidget];
QWidget *widgetToGetMouse = qwidget;
然後:
`qt_sendSpontaneousEvent(widgetToGetMouse, &qtabletEvent);`
qtabletEvent
- 不只是打電話sendSpontaneousEvent
之前接受事件創建。
然後裏面的QApplication ::通知():
QWidget *w = static_cast<QWidget *>(receiver);
QTabletEvent *tablet = static_cast<QTabletEvent*>(e);
QPoint relpos = tablet->pos();
bool eventAccepted = tablet->isAccepted();
while (w) {
QTabletEvent te(tablet->type(), relpos, tablet->globalPos(),
tablet->hiResGlobalPos(), tablet->device(), tablet->pointerType(),
tablet->pressure(), tablet->xTilt(), tablet->yTilt(),
tablet->tangentialPressure(), tablet->rotation(), tablet->z(),
tablet->modifiers(), tablet->uniqueId());
te.spont = e->spontaneous();
res = d->notify_helper(w, w == receiver ? tablet : &te);
eventAccepted = ((w == receiver) ? tablet : &te)->isAccepted();
e->spont = false;
if ((res && eventAccepted)
|| w->isWindow()
|| w->testAttribute(Qt::WA_NoMousePropagation))
break;
relpos += w->pos();
w = w->parentWidget();
}
tablet->setAccepted(eventAccepted);
我們可以看到:
res = d->notify_helper(w, w == receiver ? tablet : &te);
它通過過濾器,佈局,然後調用事件處理 - QMainWindow::tabletEven
噸。默認實現是event->ignore()
。
由於QMainWindow沒有Parent,它就是全部。 因此,平板電腦事件不涉及到QMainWindow孩子。
然後好像是QWidget *qwidget = [theView qt_qwidget];
工作不對。 不幸的是,我不能對它進行調試......
請給我一些提示...我... stucked
看看這個[post](http://qt-project.org/forums/viewthread/5974)它可能是相關的 – ixSci 2013-03-05 09:53:06
謝謝,但它是解決方法,它不會幫助我。標準QWidget :: tabletEvent()可以爲你給我的情況重載。但這不是問題。問題出現在MAC OS上。在Windows和Linux上一切都很好。 – Inq 2013-03-06 06:47:20
你的問題在很多代碼中都有擴散。什麼是你的問題?把它放在你的帖子頂部。 – UmNyobe 2013-03-07 10:13:39