How to tell the mouse button using QApplication::mouseButtons() in a “click” slot?

后端 未结 3 1866
忘掉有多难
忘掉有多难 2021-01-26 01:21

I have a QMainWindow, and want to handle the \"clicked\" signal from a smaller widget (such as tableview) inside it.

Originally I connect the signal to a slot of this QM

3条回答
  •  不知归路
    2021-01-26 01:53

    Qt::MouseButtons is a QFlags type. You can't test it with == operator. Use & operator for testing:

    if(QApplication::mouseButtons() & Qt:LeftButton) {
    ...
    }
    

提交回复
热议问题