Qt background task touch event - qt

I have a Symbian Qt "background" app that displays a button type thing using CWindowDrawer derived from CActive that is visible on top of everything. I want it to be visible when the a textinput is active or the virtual keyboard is visible, preferably when a textinput is active because some phones have a hardware keyboard. When it is visible I want it to receive all touch positions as to determine if it is being pressed without it taking focus and closing the keyboard?
Basically I need a way to determine when a textinput is activated and I need a way to listen for all touch positions from a non qwidget that is also not in focus.
Any help would be appreciated.
PS. This is for Symbian Belle and Symbian C++ is also supported within a Qt application if necessary.

Related

QToolButton Remain Pressed after finger has been removed from Touchscreen

I have a small Qt Desktop application (in C++) which I need to make it work in a touch screen device running Window 10. The device has a touchscreen and application works perfectly with keyboard and mouse.
I am not expert in developing Qt Application and that's why unable to resolve this could be silly isssue.
However, when I try to use touchscreen, the last touched QToolbutton remain pressed even if I have moved my finger away from the touchscreen and when I touch somewhere else, then that QToolButton is released.
I expect the Qtoolbutton to behave just like when it is pressed using a mouse. Once I move my finger off the touchscreen, it should be released.
I tried to resolve this issue with the following:
btn->setAttribute(Qt::WA_AcceptTouchEvents);
And
qApplication.setAttribute(Qt::AA_SynthesizeMouseForUnhandledTabletEvents);
But it didn't help. I think I am missing a very small issue and after that Qt will handle all the touch related events on it's own and will show the right behavior.
I am cross-compiling on my Ubuntu machine using MXE. Qt version is 5.12.
I think I am missing a very small issue and after that Qt will handle all the touch related events on it's own and will show the right behavior.
QWidget subclasses, including QToolButton, do not handle touch events on its own. It is not even needed that Qt emulate mouse events. You are seeing the effects in your application of emulated mouse events synthesized by Windows. This makes possible for ancient Windows programs designed to be used with mouse will work somewhat in modern touch enabled Windows tablets. But the mouse emulation is hardly perfect.
If the behavior is unacceptable for the QToolButton class, you have the option of subclass it and handle touchevents as you see fit, overriding mouse events as well, to avoid the synthesized events to be handled as well.
I had the same problem. I solved it by changing the signal to which the slot is connected.Previously I was connected my slot to QPushButton::pressed. To fix it, change the connect to use the signal QPushButton::clicked:
connect(my_button, &QPushButton::clicked, this, &MyClass::onMyButtonClicked);

How to hide mouse cursor in Qt Application?

qApp->setOverrideCursor() method works successfully, if I want to hide mouse cursor, except one condition. If I add a dialog that is modal, and while it is shown, if the cursor is out of dialog's borders, it is shown again. Have you got any idea about the problem?
It does not matter how the solution for hiding mouse cursor is; whether by Qt or at the operating system level. My operating system is Windows 7.
You cannot hide the mouse cursor when it leaves your window (or dialog-window), because it is then handled by the window-manager of your OS. A workaround would be to constrain the mouse to your window/dialog, so it cannot leave. You will either need to look through the MSDN to find the specific windows functions to do it, or do it like in kshegunov's code example on the Qt-forums: https://forum.qt.io/topic/61832/restrict-mouse-cursor-movement/12

capture mouse wheel events outside qwidget

I have a qwidget derived control.
I need to capture mouse wheel events outside the control / window if the mouse is button is pressed inside the control then the mouse is moved outside.
Mouse move events are captured wheel events are not.
Qt calls capturemouse when button is pressed.
I don't mind doing specific conditional statements for this if necessary.
I am testing on Ubuntu 16.04 and intend to cross compile for windows and possibly Mac,
Set widget focus policy to Qt::WheelFocus.
setFocusPolicy(Qt::WheelFocus);

Qt creator - make a dynamic interface

I am working on a small UI with QT Creator and its drag-n'-drop tool (QT Designer). Everything was fine till I realized I had to make some widgets dynamic. For example, I have a checkbox and I want some button to appear only if this checkbox is checked by the user or I would like to change the appearance of another widget when the user clicks on some button.
Is it possible to do it only with QT Designer?
Yes, but it's very limited.
Qt designer have signal&slot editor. Yes, you can connect signal clicked(bool) to setVisible(bool) slot on button and make button visible only when checkbox is checked (see screenshot).
But when You need more complex dynamic interface (e.g. creating buttons), designed will not help You.

Getting the keyevent info from Virtual Keyboard of symbian touch devices

Is there any way to obtain the keypress info for the green-tick (green check marked key) present in the input panel/ virtual keyboard?
Our application is for symbian touch devices. In my application I wanted the url to start loading as soon as the QLineEdit has been edited i.e., as soon as the green check marked key in VKB has been pressed.
I tried using the CloseSoftwareInputPanel event to get notified when the editing is completed in the QLineEdit i.e., when the green check marked key is pressed in the VKB, but that event occurs only after the QLineEdit loses focus (when I tap anywhere on the screen). Is there any other way to get it done?
Thanks
The virtual keyboard is implemented as a front-end processor (FEP) and it's quite invisible to applications.
Note that there are Symbian touch devices that also have a physical keyboard. Not for those devices alone, you should have a Go button or similar and observe returnPressed signal.

Resources