如何定義onmouseover並單擊QLineEdit事件?我要讓2個信號作爲的onmouseover(),並點擊()爲QLineEdit的onmouseover並單擊事件QLineEdit
0
A
回答
1
我怕,你必須繼承QLineEdit
和覆蓋void mouseMoveEvent (QMouseEvent * event)
和void mousePressEvent (QMouseEvent * event)
(或void mouseReleaseEvent (QMouseEvent * event)
如果你願意的話)。不要忘記撥打setMouseTracking(true);
來追蹤鼠標移動,當沒有鼠標按鈕時。
3
您可以在您的QLineEdit上安裝event filter。
下面是一個例子:
QLineEdit *line_edit = new QLineEdit(this);
ui->verticalLayout->addWidget(line_edit);
line_edit->installEventFilter(this);
而在你的事件過濾功能,你可以做這樣的事情:(這是你重寫一個函數)
bool MainWindow::eventFilter(QObject *obj, QEvent *event)
{
if(event->type() == QEvent::MouseButtonPress)
{
qDebug() << "CLICK";
}
if(event->type() == QEvent::MouseMove)
{
qDebug() << "MOUSE OVER";
}
return false;
}
相關問題
- 1. PyQt:點擊事件清除QLineEdit
- 2. QLineEdit焦點事件
- 3. QLineEdit - 焦點事件
- 4. 單擊並雙擊事件觸發
- 5. Raphael.js onmouseover onmouseout事件
- 6. Silverlight ListBox OnMouseOver事件
- 7. 多個onmouseover事件
- 8. Coqsoft treegrid單元中的OnMouseOver事件
- 9. 單擊事件
- 10. 單擊事件充當雙擊事件
- 11. 更改類並添加單擊事件
- 12. D3單擊並拖動事件築巢
- 13. 複選框並單擊事件處理
- 14. jqxgrid handlekeyboardnavigation事件並單擊標籤
- 15. 鼠標單擊並拖動事件WPF
- 16. JavaScript的問題 - onmouseover事件
- 17. onmouseover事件行爲異常
- 18. jQuery防止onmouseover事件
- 19. MenuBar單擊事件
- 20. Plotly.js單擊事件
- 21. IOS事件單擊
- 22. CollapsiblePanelExtender單擊事件
- 23. 上單擊事件
- 24. Raphael.js單擊事件
- 25. TextBoxButton單擊事件
- 26. oop:單擊事件
- 27. JTabbedPane單擊事件
- 28. JavaScript單擊事件
- 29. ColdFusion單擊事件?
- 30. 嘗試解除綁定單擊事件並附加新事件