Handle Left-Right Double Click on QListWidget
-
I still need help I'm afraid :(
-
This method works and I checked it before posting so there must be something else in your app interfering with it. Can you post somewhere the complete project or, better yet, a small reproducible code that doesn't work with this method?
Oh, I forgot to ask which OS are you on. On Windows the double-click signal is emitted before the final release so mouseButtons() has meaningful info. This might not be the case on other platforms.
-
I am using X-ubuntu (latest LTS).
Well what is qApp exactly? I do declare in main
@QApplication app(argc, argv);@
but I can't rename app into qApp for some reason.
-
Hi,
qApp is a macro used to get the current instance of your QApplication. "Here":http://qt-project.org/doc/qt-5/qapplication.html#qApp for more informations
-
I see thanks.
So does this mean my problem has no solutions on Linux?
-
Maybe you can subclass the list widget, reimplement the mouse press/release event and emit a custom signal that would indicate which button was pressed.
-
Oh okay. I'm a newbie regarding Qt unfortunately, I would really need to see very similar examples so that I could get this done.
This is surprising that so simple a problem needs such complicated solutions, though.
-
Well it might be a simple case for you but right button double clicks are not something you see every day. I would even dare to say that's unintuitive.
For some info and examples on overloading event handlers you can go "here":http://qt-project.org/doc/qt-5/eventsandfilters.html#event-handlers
There's also a lot of that stuff on the net. Just look for "qt overriding mousepressevent" eg. "here":http://stackoverflow.com/questions/2733668/qwidget-keypressevent-override -
Okay before trying the long way to do it, I replaced the itemDoubleClicked signal by simply itemClicked. I still print neither "haha" nor "hoho" after the second click (when I double click). Are you sure Ubuntu is the problem here?
buttons is always equal to 0 (when I print it)
-
If you really want to implement the non-standard double right click (you might even be going against the guidelines from Apple/Microsft/etc.), you should rather look at the mouse events functions.