10

I'm in a ArchLinux with OpenBox and I want to hide the cursor on fullscreen inside a Qt 4.8 application. I am aware about some other question about it but no one works every time: sometimes the cursor is hiding, sometimes not. I didn't managed to understand exactly when the problem occurs but I think that maybe is it related with the screensaver because if I test my application just after the computer is restarted the mouse cursor is no visible (and it is what I want) but if I test this feature during the day the mouse cursor is still visible in fullscreen.

This is my code:

void MainWindow::toggleFullScreen()
{
    if(!this->isFullScreen())
    {
        this->showFullScreen();
        #ifdef Q_WS_QWS
            QWSServer::setCursorVisible( false );
        #endif

    }
    else
    {
        this->showNormal();
    }
}
jww
  • 97,681
  • 90
  • 411
  • 885
nkint
  • 11,513
  • 31
  • 103
  • 174
  • Also see [How to hide mouse pointer in Qt app at startup?](https://stackoverflow.com/q/44005653/608639) – jww Dec 10 '19 at 20:49

2 Answers2

22

I want to hide the cursor on fullscreen ...

You could set the cursor to be the blank cursor:

widget->setCursor(Qt::BlankCursor);

Also, as the docs state:

Some underlying window implementations will reset the cursor if it leaves a widget even if the mouse is grabbed. If you want to have a cursor set for all widgets, even when outside the window, consider QApplication::setOverrideCursor().

So you can call:

QApplication::setOverrideCursor(Qt::BlankCursor);
jww
  • 97,681
  • 90
  • 411
  • 885
TheDarkKnight
  • 27,181
  • 6
  • 55
  • 85
1

There is a program named unclutter that hides the mouse pointer. Here's an ArchLinux package:

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

I currently use it on an embedded system for hiding the mouse cursor on a touchscreen.

Rob
  • 11,492
  • 14
  • 59
  • 94