英文:
How to change cursor size in PyQt5?
问题
我想实现像大多数图像编辑器中的画笔光标,当光标是一个圆圈时,根据画笔大小改变其大小。我已经阅读了文档,并只找到了setShape
方法,但没有setSize
。在Qt中是否可以更改光标大小?
英文:
I want to implement brush cursor like in most image editors when cursor is a circle that change its size according to brush size. I've read the docs and found only setShape
method, but no setSize
. Is it possible in Qt to change cursor size?
答案1
得分: 1
pixmap = QPixmap("image.png") # 替换为您自定义光标图像的路径,刷子在您的情况下
pixmap = pixmap.scaled(30, 30) # 设置所需的大小
cursor = QCursor(pixmap)
self.setCursor(cursor)
您可以通过创建一个 pixmap,然后将其分配给光标,在 PyQt5 中更改光标的大小和 "形状"。
英文:
pixmap = QPixmap("image.png") # Replace with the path to your custom cursor image, brush in your case
pixmap = pixmap.scaled(30, 30) # Set the desired size
cursor = QCursor(pixmap)
self.setCursor(cursor)
you can change the size and the "form" of your cursor in PyQt5 by creating a pixmap and then assigning in to your cursor
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论