2012-09-21 40 views

回答

0

我不認爲這是直接可能的,至少如果您將樣式表應用於QGraphicsView本身,它不會影響其中的任何小部件。但是,您可以將其添加到場景之前指定一個樣式表到窗口小部件,那麼它會保持它的風格被添加後:

QGraphicsScene scene; 
QPushButton b; 

b.setStyleSheet("QPushButton{background-color:red}"); 
scene.addWidget(&b); 

QGraphicsView view(&scene); 
view.show(); 
+0

好吧,這是一個很好的把戲。但我認爲我說得對,當我說「基於GraphicsView的」對象(不是老派的Widget)都沒有setStyleSheet方法。所以他們的外觀應該使用Pallets進行定義,並在重寫的Paint函數中使用QPainter進行繪製。 –