我已經打過電話self.setStyleSheet("background: transparent; border: transparent;")
上的QGraphicsView的邊界,但仍留下了1個像素的邊框上的頂邊。我也試圖與border-style: none;
更換border: transparent;
,但它也不能工作。無法完全去除的PyQt的QGraphicsView
這是問題的一個截圖:
什麼命令將完全從的QGraphicsView刪除邊框?
我已經打過電話self.setStyleSheet("background: transparent; border: transparent;")
上的QGraphicsView的邊界,但仍留下了1個像素的邊框上的頂邊。我也試圖與border-style: none;
更換border: transparent;
,但它也不能工作。無法完全去除的PyQt的QGraphicsView
這是問題的一個截圖:
什麼命令將完全從的QGraphicsView刪除邊框?
您可以使用下面的CSS規則之一:
graphicsView.setStyleSheet("border-width: 0px; border-style: solid")
或
graphicsView.setStyleSheet("border: 0px")
你的邊界應該消失。
import sys
from PyQt4.QtGui import *
class Ui(QWidget):
def __init__(self, parent=None):
QWidget.__init__(self, parent)
graphicsView = QGraphicsView()
graphicsView.setStyleSheet("border: 0px")
grid = QGridLayout()
grid.addWidget(graphicsView)
self.setLayout(grid)
app = QApplication(sys.argv)
ui = Ui()
ui.show()
sys.exit(app.exec_())
這裏是默認樣式的小工具:
http://i.stack.imgur.com/gpwaW.png
而現在應用的風格的小部件:
如果QGraphicsView
是頂級窗口,嘗試:
self.setContentsMargins(QMargins())
如果沒有,你叫QGraphicsView
和頂層窗口之間的每一個佈局和窗口小部件相同的功能(該功能在這兩個類中定義)。
PS:QMargins()
是QtCore的一部分,當它的構造函數被調用不帶任何參數,四個邊距設置爲0。
有用的提示,但它不是刪除線。 –
你舉的例子有同樣的問題。我用截圖更新了這個問題。 –
我提供的例子是在Mac OS X和Windows上工作,你使用的是什麼版本的Qt/PyQt?我在PyQt Qt 4.7.3和4.8.3上。從我在屏幕截圖上看到的,你已經有了一個佔據你窗口的風格,你確定它不覆蓋你的樣式表嗎? –
我在Kubuntu 11.04上使用Qt 4.7.2。花哨的窗口顏色只是我的系統主題;甚至在使用默認主題時也會出現問題。 –