[英]Qt QGraphicsView and StyleSheets
Can I use CSS/stylesheets to style a item in QGraphicsView, like QGraphicsWidget? 是否可以使用CSS /样式表在QGraphicsView中为项目设置样式,例如QGraphicsWidget? If yes, how?
如果是,怎么办?
I don't think it's directly possible, at least if you apply a stylesheet to the QGraphicsView
itself it will not affect any widgets inside of it. 我不认为这是直接可能的,至少如果您将样式表应用于
QGraphicsView
本身,它将不会影响其中的任何小部件。 However, you can assign a stylesheet to a widget before adding it into the scene, then it will keep it's style after being added: 但是,您可以在将样式表添加到场景之前为其分配样式表,然后在添加后将保持其样式:
QGraphicsScene scene;
QPushButton b;
b.setStyleSheet("QPushButton{background-color:red}");
scene.addWidget(&b);
QGraphicsView view(&scene);
view.show();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.