Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我可以使用 CSS/样式表为 QGraphicsView 中的项目设置样式,例如 QGraphicsWidget 吗?如果是,如何?
我认为这不是直接可能的,至少如果您将样式表应用于QGraphicsView自身,它不会影响其中的任何小部件。但是,您可以在将小部件添加到场景之前为其分配样式表,然后在添加后它将保持其样式:
QGraphicsView
QGraphicsScene scene; QPushButton b; b.setStyleSheet("QPushButton{background-color:red}"); scene.addWidget(&b); QGraphicsView view(&scene); view.show();