QMousepressEvent is ignored by exec method
-
hi,
I have the following problem, I use the exec method to display the top menus of my text editor, and I also have an implementation of the mousepressEvent method. This last method is ignored when I use the exec method, what I expect my program to do is that once my menu is displayed by left clicking on my mouse, the corresponding action of my menu is activated.
-
@Oumayma Hello I have solved my problem in the following way:
#ifdef Q_OS_ANDROID if(QEvent::MouseButtonPress){ evento_mouse = new QMouseEvent(QEvent::MouseButtonPress, cursor.pos(),Qt::LeftButton,Qt::LeftButton, Qt::NoModifier); mousePressEvent(evento_mouse); } #endif
I have this code just after displaying my menu.
-
@jsulm
Hi, sorry for not explaining myself correctly, the problem I have is when I run my text editor on Android. It is a bit complicated to explain since my editor is designed for people with functional diversity that can only be managed with mouse clicks or a button.To display the submenus as I was commenting, I have a function that I pass the menu to be displayed and its global position and using menu->exec(point) my menu is displayed.
Once the menu is displayed, the actions are highlighted one by one through a timer waiting for the user to left click on the mouse to execute the desired action, for this I need the interaction of the mousepressevent method. What I have just commented on in windows works fine, but in android when making a single click the dropdown menu closes without executing the desired action, it seems that android needs a second click to execute said action.
I hope that with this message I have explained myself better, anyway if you need more details or something more specific to understand my problem let me know.
Thank you very much.
-
@Oumayma said in QMousepressEvent is ignored by exec method:
but in android when making a single click the dropdown menu closes without executing the desired action
Do you mean mousePressEvent() is not executed?
-
@jsulm yes, i said that. But I did not express myself in the correct way, what I wanted to say is that the mousepreesevent method in Android, instead of executing the action that is highlighted, such as copying a text with the first click, what it does is hide the dropdown menu. To execute the desired action, you need a double click. This only happens to me with Android.
-
@Oumayma Hello I have solved my problem in the following way:
#ifdef Q_OS_ANDROID if(QEvent::MouseButtonPress){ evento_mouse = new QMouseEvent(QEvent::MouseButtonPress, cursor.pos(),Qt::LeftButton,Qt::LeftButton, Qt::NoModifier); mousePressEvent(evento_mouse); } #endif
I have this code just after displaying my menu.