本文介绍了如何在启动时在Qt应用程序中隐藏鼠标指针?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个小的Qt应用程序,可以在屏幕上显示图像(有关更多信息,请参见此处的源代码:).

I have a small Qt application that displays an image to the screen (more on that including source code here: Qt: Modify alpha channel transparency of a windowless QLabel).

默认情况下,Qt会在图像上方插入鼠标指针.对于我的应用程序,我不需要与Qt进行任何物理用户交互,因此不需要鼠标指针.

By default, Qt is inserting a mouse pointer on top of my image. For my application, I do not need any physical user interaction with Qt and thus have no need for a mouse pointer.

我使用以下代码隐藏了鼠标指针,但是仅在鼠标物理移动后才隐藏鼠标,并且仅在显示的图像内隐藏鼠标.如果我的图像小于显示区域,则可以在此空间中自由移动鼠标指针.

I have used the following code to hide the mouse pointer, but it only hides the mouse once the mouse has been physically moved, and only within the displayed image. If my image is smaller than the display area, I can freely move the mouse pointer through this space.

int main (int argc, char *argv[])
{
    QApplication app(argc, argv);

    // Try to hide the cursor
    app.setOverrideCursor(QCursor(Qt::BlankCursor));

    return app.exec();
}

启动应用程序时,如何隐藏鼠标指针而不需要实际移动鼠标?

How can I hide the mouse pointer when I start my application without the need to actually move the mouse?

我正在嵌入式设备上运行Qt版本4.8.4.

I am running Qt version 4.8.4 on my embedded deivce.

(此外,我正在运行没有QWidget窗口的应用程序.因此,我正在寻找不需要此功能的解决方案).

(Also, I am running my application without a QWidget window. So I am looking for solutions that does not require this).

推荐答案

我找到了一个命令行选项"-nomouse",似乎可以解决问题.这不是我理想的解决方案,但目前仍然有效.

I found a command line option, "-nomouse", that seems to do the trick. It is not my ideal solution, but it works for now.

$ ./my-Qt-application -nomouse

http://doc.qt.io/qt-4.8/qt-embedded-running.html (在命令行选项下搜索-nomouse)

http://doc.qt.io/qt-4.8/qt-embedded-running.html (search for -nomouse under the Command Line options)

这篇关于如何在启动时在Qt应用程序中隐藏鼠标指针?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 15:18
查看更多