您的位置:首页 > 其它

【转载】关于graphicsview背景透明的问题

2013-09-17 12:53 991 查看
#include <QtGui>

int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QMainWindow window;

QGraphicsScene* scene = new QGraphicsScene(&window);
QGraphicsItem* item = scene->addText("QGraphicsTextItem");
item->setFlags(QGraphicsItem::ItemIsMovable);

QGraphicsView* view = new QGraphicsView(&window);
view->setStyleSheet("background: transparent");  //就是这句可以设置透明
view->setScene(scene);
window.setAttribute(Qt::WA_TranslucentBackground);
window.setWindowFlags( Qt::FramelessWindowHint) ;
window.setCentralWidget(view);
window.setStyleSheet("background: green");
window.show();
return app.exec();
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: