1
在我的QWidget中有一些像QLineEdit和QLabels的小工具。我可以很容易地检查我的鼠标是否在QLabel上,是否点击了右键。不像QLineEdit。 我试图继承QLineEdit并重新实现mouseRelease,但它永远不会被调用。 findChild方法是从我的UI中获取相应的小部件。如何检测鼠标点击QLineEdit
我该如何获得鼠标释放并在QLineEdit中使用鼠标左键或右键?在标签上
void Q_new_LineEdit::mouseReleaseEvent(QMouseEvent *e){
qDebug() << "found release";
QLineEdit::mouseReleaseEvent(e);
}
m_titleEdit = new Q_new_LineEdit();
m_titleEdit = findChild<QLineEdit *>("titleEdit",Qt::FindChildrenRecursively);
点击确认,但QLineEdit的点击是不,象下面这样:
void GripMenu::mouseReleaseEvent(QMouseEvent *event){
if (event->button()==Qt::RightButton){
//get click on QLineEdit
if (uiGrip->titleEdit->underMouse()){
//DO STH... But is never called
}
//change color of Label ...
if (uiGrip->col1note->underMouse()){
//DO STH...
}
}
可能的重复http://stackoverflow.com/questions/6452077/how-to-get-click-event-of-qlineedit-in-qt – user2672165
我读过这个,它没有工作...在'eventFilter'中,我无法检查它是左边还是右边的鼠标按钮... – user2366975
好的,但是如果你认为在你的实现中有什么错误,获得帮助的唯一方法就是发布它。当然只有相关的代码应该发布。 – user2672165