是否有方法将鼠标光标图标行为重置为windows默认值
当一个长进程运行时,我想显示一个等待的鼠标光标图标,它完成了任务:
# Set the mouse cursor to wait cursor
QtWidgets.QApplication.setOverrideCursor(QtGui.QCursor(QtCore.Qt.WaitCursor))
# Long process start
# Long process end
#reset mouse cursor to default behaviour
QtWidgets.QApplication.restoreOverrideCursor()
问题在于,在漫长的过程中,我运行的方法或事件或任何同时调用setOverrideCursors的东西:
# Set the mouse cursor to wait cursor
QtWidgets.QApplication.setOverrideCursor(QtGui.QCursor(QtCore.Qt.WaitCursor))
# Long process start
# In the long process theres a method or event or whatever that calls again the wait cursor
# and wait cursor becomes the overwritten mouse cursor
QtWidgets.QApplication.setOverrideCursor(QtGui.QCursor(QtCore.Qt.WaitCursor))
# Some code running...
QtWidgets.QApplication.restoreOverrideCursor()
# Long process end
# the restoreOverrideCursor() restores the wait cursor instead of the default mouse cursor behaviour
# and the mouse icon just spinning forever
QtWidgets.QApplication.restoreOverrideCursor()
我尝试了这个,而不是restoreOverrideCursor():
QtWidget.QApplication.setOverrideCursor(QtGui.QCursor(QtCore.Qt.ArrowCursor))
但问题是,它会用箭头光标、示例窗口大小调整图标等编写每个行为
有没有办法恢复PyQt5中默认的鼠标行为
要确保重置默认光标,可以执行以下操作:
这是必需的,因为Qt维护一个覆盖游标的内部堆栈,并且restoreOverrideCursor只撤消最后一个
相关问题 更多 >
编程相关推荐