如何使用PyQt更改光标形状? [英] How can I change the cursor shape with PyQt?

查看:717
本文介绍了如何使用PyQt更改光标形状?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的应用程序,运行一个过程,可以持续几分钟前完成。所以我试图向用户提供一个指示器,它正在处理请求,例如将光标更改为沙漏。

I have a simple application that runs a process that can last for several minutes before completing. So I am trying to provide an indicator to the user that it is processing the request, such as changing the cursor to an hourglass.

但我不能让它工作对。我的所有尝试都导致错误或没有效果。并且我似乎错误地调用cursorshapes PyQt4.Qt.WaitCursor返回一个错误,模块不包含它。

But I cannot quite get it to work right. All of my attempts have resulted in either an error or had no effect. And I seem to calling the cursorshapes incorrectly PyQt4.Qt.WaitCursor returns an error that the module does not contain it.

什么是正确的方式向用户表明该过程正在运行?

What is the correct way to indicate to the user that the process is running?

推荐答案

我认为 QApplication.setOverrideCursor 是您要查找的内容:

I think QApplication.setOverrideCursor is what you're looking for:

from PyQt4.QtCore import Qt
from PyQt4.QtGui import QApplication
...
QApplication.setOverrideCursor(Qt.WaitCursor)
# do lengthy process
QApplication.restoreOverrideCursor()

这篇关于如何使用PyQt更改光标形状?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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