使用Qt 4.8在全屏模式下隐藏光标? [英] Hide cursor in fullscreen mode using Qt 4.8?

查看:229
本文介绍了使用Qt 4.8在全屏模式下隐藏光标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在带有OpenBox的ArchLinux中,我想将光标全屏隐藏在Qt 4.8应用程序中.我知道与此有关的其他问题,但是没有人每次都起作用:有时光标隐藏了,有时没有.我没有确切了解问题何时发生,但是我认为这可能与屏幕保护程序有关,因为如果在计算机重新启动后立即测试我的应用程序,则鼠标光标不可见(这正是我想要的),但是如果我在白天测试此功能,则鼠标光标仍在全屏状态下可见.

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.

这是我的代码:

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

    }
    else
    {
        this->showNormal();
    }
}

推荐答案

我想在全屏上隐藏光标...

I want to hide the cursor on fullscreen ...

您可以将光标设置为空白光标:

You could set the cursor to be the blank cursor:

widget->setCursor(Qt::BlankCursor);

此外,如文档所述:

即使鼠标被抓住,一些底层的窗口实现也会在光标离开窗口小部件时重置光标.如果要为所有窗口小部件设置光标,即使在窗口外,也请考虑QApplication::setOverrideCursor().

因此您可以致电:

QApplication::setOverrideCursor(Qt::BlankCursor);

这篇关于使用Qt 4.8在全屏模式下隐藏光标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆