无法完全删除 PyQt QGraphicsView 的边框
我曾尝试在 QGraphicsView 上调用 self.setStyleSheet("background:transparent; border:transparent;"),但它仍然在顶部边缘留下 1 像素边框。我也尝试过用 border-style: none;
替换 border:transparent;
,但它也不起作用。
这是问题的屏幕截图:
什么命令将完全从 QGraphicsView 中删除边框?
I have tried calling self.setStyleSheet("background: transparent; border: transparent;")
on a QGraphicsView, but it still leaves a 1 pixel border on the top edge. I have also tried replacing border: transparent;
with border-style: none;
, but it didn't work either.
Here is a screenshot of the problem:
What command will fully remove the border from the QGraphicsView?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用以下 css 规则之一:
或者
您的边框应该消失。
这是具有默认样式的小部件:
现在应用了样式的小部件:
You can use one of the following css rule:
or
Your border should disappear.
Here is the widget with the default style:
And now the widget with the style applied:
如果 QGraphicsView 是顶级窗口,请尝试:
如果不是,则在 QGraphicsView 之间的每个布局和小部件上调用相同的函数(该函数在两个类中定义)和顶层窗口。
PS:
QMargins()
是QtCore的一部分,当不带任何参数调用其构造函数时,四个边距设置为0。If the
QGraphicsView
is the top level window, try:If not, you call the same function on every layouts and widgets (the function is defined in both classes) between the
QGraphicsView
and the top level window.PS:
QMargins()
is part of QtCore, and when its constructor is called without any parameters, the four margins are set to 0.