Cross compiling qml app and mouse focus issue - qt

When I cross compile my qml app on raspberry3 , the mouse cursor disables and touch screen of the program works well .
But when I run the program on raspberry by command line , as I touch the screen ,
mouse cursor moves on app , and It seems that every movements and actions of mouse in the program , happens outside the program on the screen of raspberry too!!!
(all movements , clicks and everything!)
But I want the focus of the mouse be disabled on the screen of rasp when I run the program on it; like the situation of cross compiling the program on rasp.

You can disable mouse cursor in your application by using this line in your main.cpp
QGuiApplication::setOverrideCursor(Qt::BlankCursor);
This will permanently disable mouse cursor inside your app but it will be appear outside it.

Related

Showing a QMessageBox breaks QLineEdit highlighting

I have a C++ Qt 4 application written for Raspberry Pi. I'm experiencing an odd side-effect of showing a QMessageBox and I don't know enough about Qt to debug it.
The pi has a touchscreen, so I launch the application with unclutter to hide the mouse cursor. (Though this doesn't affect my issue... I have tried without unclutter just in case.)
I have sub-classed QLineEdit to override focusInEvent() and focusOutEvent() to select-all when a LineEdit gets focus, and deselect-all when it loses focus.
Before showing any QMessageBoxes, everything works perfectly - tapping on a QLineEdit selects all the text; tapping the next one de-selects the previous QLineEdit, and selects the new QLineEdit.
After showing a QMessageBox, my overridden events stop working, and QLineEdits no longer auto-select and de-select.
If I add:
msgBox.setWindowFlags(msgBox.windowFlags() | Qt::Popup);
before I exec() the QMessageBox, then text highlighting continues working normally, but the cursor is displayed and flickers while the QMessageBox is on the screen.
It seems like there is a side-effect of showing the QMessageBox that affects the calling window and my sub-classed QLineEdit boxes... but not if the QMessageBox has the Popup flag set!
I've tried storing and manually re-loading the flags on the main window, and that does nothing, so it doesn't appear to be flags on the main window.
One more oddity: everything works fine if I run the application remotely over XMing and SSH... it's only when it's run locally on the Pi in plain-old X11 that it freaks out.
Any thoughts on how to debug this? Thank you!
I was able to work around this by doing two things.
First, I updated the flags of the QMessageBox before opening it:
msgBox.setWindowFlags(Qt::Popup);
msgBox.exec();
and second, I hid the cursor in Qt code, rather than relying on Unclutter; this fixed the flickering cursor issue:
QApplication::setOverrideCursor(Qt::BlankCursor);

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);

How to minimize window when the taskbar icon is clicked?

I have a Qt application with borderless window. So, I am creating my application window with CreateWindow() and then I have QWidget which uses the HWND.
Everything works fine, except that when the application is maximized and the Windows taskbar is set to auto-hide. In that case, if I click on the application icon, the program is not minimized. Even stranger is the fact that this only happens if the application is on my primary monitor. If it's on another monitor, everything works fine. Or, if the taskbar is not set to auto-hide, everything works fine on any monitor.
When the taskbar is set to auto-hide, on my primary screen the taskbar wasn't even showing up, so I am showing it with ShowWindow(hTaskbar, SW_SHOW). When it shows up, everything works when I click on the icons of other applications, so there must be something wrong with mine, but I am not sure where to start.
You need to handle WM_SYSCOMMAND and respond to SC_MINIMIZE.
WM_SYSCOMMAND on MSDN

hide system cursor in system wide

I want to hide system cursor for 10s for some reason ,but I found
cursor.setShape(Qt.BlankCursor)
can only hide mouse cursor that is associated with QWidgets ,not in system wide ,i.e. when mouse cursor is hovering on QWidgets, it is invisible ,otherwise it is visible ,so is there any way to hide system cursor in system wide?
The win32 system call ShowCursor works per-window only. You can access this from either ctypes or pywin32's win32api. But apparently the cursor drawing is controlled by display driver and can only be affected by specific windows. You can't force another window to hide its cursor. Two options:
use ShowCursor(False) on your window, and for the display background, create a root window application that you spawn from your GUI app, it hides cursor; your app would cause it to exit after 10 seconds, but again if user moves mouse over other app windows they will see cursor.
make your application a root window application; then while in view, ShowCursor(False) will make cursor disappear everywhere on screen except system toolbar (which is a good thing).
I don't think it is a good idea anyways; what if your app crashes while the mouse is hidden? Then user can't use their desktop easily. Definitely good reason that this is not allowed.
Best approach is to think of a different solution to whatever problem led you to try cursor hiding.

Qt background task touch event

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.

Resources