本文介绍了为什么矩形部分在视图之外绘制为三角形?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 PySide 中的 Python-Qt 绑定,我想绘制一个场景,其中包含一个矩形,但该矩形不完全可见,因为该视图应仅显示该矩形未完全包含的场景的一部分.

I use the Python-Qt bindings from PySide and I want to draw a scene with amongst others a rectangle and the rectangle is not fully visible because the view should only show a part of the scene where the rectangle is not fully contained.

这是一个最小的例子:

from PySide.QtGui import *

app = QApplication([])

scene = QGraphicsScene()
scene.addRect(0, 0, 100, 100)
view = QGraphicsView(scene)
view.setSceneRect(-60, 20, 100, 100)
view.show()

app.exec_()

我希望看到的是矩形的下部,而不是三角形的下部!

I expect to see the lower part of a rectangle instead I see the lower part of a triangle!

好像没有考虑矩形的右下角.

It seems like the lower right corner of the rectangle is not taken into account.

三角形仅在特殊情况下出现(如示例中的特殊场景矩形),如果整个矩形可见,则不会出现.

The triangle only appears for special cases (like the special scene rect in the example) and does never occur if the full rectangle is visible.

这是一个错误还是我做错了什么?能修吗?

Is this a bug or am I doing something wrong? Can it be fixed?

我的系统:Windows 7 上的 Python 3.3 + PySide 1.2.2(64 位)

My system: Python 3.3 + PySide 1.2.2 (64 bit) on Windows 7

推荐答案

这是一个错误,同时已修复,至少对于 Qt 和 Python 的某些组合.

It was a bug and it is fixed in the meantime, at least for some combinations of Qt and Python.

我现在使用 Windows 10、Python 3.5、PyQt5,矩形显示为矩形.

I now use Windows 10, Python 3.5, PyQt5 and the rectangle is shown as rectangle.

很难找出 PySide/PyQt 和 Qt 4.X 或 5.x 和 Python 2.X 或 3.X 或 Windows、Linux、Mac 的哪些版本存在错误,哪些不存在.我没有错误地报告错误,但我想因为它现在可以与我所拥有的错误一起使用,所以对任何人来说都不是首要任务和/或可能已经修复.

It's difficult to find out for which versions of PySide/PyQt and Qt 4.X or 5.x and Python 2.X or 3.X or Windows, Linux, Mac .. the bug is present and for which not. I did not erport the error but I guess since it works right now with what I have the bug would not be top priority for anyone and/or may already be fixed.

这篇关于为什么矩形部分在视图之外绘制为三角形?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 19:43