Qt 4.8 Hide cursor in full screen mode

I am in ArchLinux with OpenBox, and I want to hide the cursor in full screen mode in a Qt 4.8 application. I know about some other question, but no one works every time: sometimes the cursor hides, sometimes not. I was not able to understand exactly when the problem occurs, but I think that this may be due to the screensaver, because if I test my application right after restarting the computer, the mouse cursor will not be visible (and this is what I want), but if I test this function during the day, the mouse cursor is still displayed in full screen.

This is my code:

void MainWindow::toggleFullScreen() { if(!this->isFullScreen()) { this->showFullScreen(); #ifdef Q_WS_QWS QWSServer::setCursorVisible( false ); #endif } else { this->showNormal(); } } 
+6
source share
2 answers

You can set the cursor as an empty cursor: -

widget-> SetCursor (Qt :: BlankCursor);

In addition, as indicated in the documents: -

In some basic window implementations, the cursor will be reset if it leaves the widget, even if the mouse is captured. If you want to set the cursor for all widgets, even outside of it, consider QApplication :: setOverrideCursor ().

So you can call: -

 QApplication::setOverrideCursor(Qt::BlankCursor); 
+14
source

There is a program called unclutter that hides the mouse pointer. Here is the ArchLinux package:

https://www.archlinux.org/packages/community/i686/unclutter/

I am currently using it in the embedded system to hide the mouse cursor on the touch screen.

+1
source

Source: https://habr.com/ru/post/957917/


All Articles