急求2D图形解决方案
目的:点击某个按钮后,在主界面的graphicsView出显示一个图形。
主要参考Qt Demo里的embeddeddialog例子
GroupDialog是另外写的一个简单对话框,遇到的问题是无法显示该对话框在group_graphicsView上,求高手指点,谢谢!
代码:
QGraphicsScene scene; scene.setStickyFocus(true); QGraphicsProxyWidget *proxy = new QGraphicsProxyWidget(0, Qt::Window); proxy->setWidget(new GroupDialog); QRectF rect = proxy->boundingRect(); proxy->setPos(rect.width(), rect.height()); proxy->setCacheMode(QGraphicsItem::DeviceCoordinateCache); scene.addItem(proxy); scene.setSceneRect(scene.itemsBoundingRect()); qDebug()<<&scene.items(); ui->group_graphicsView->setScene(&scene); qDebug()<<ui->group_graphicsView; //ui->group_graphicsView->scale(0.5, 0.5); ui->group_graphicsView->setRenderHints(ui->group_graphicsView->renderHints() | QPainter::Antialiasing | QPainter::SmoothPixmapTransform); ui->group_graphicsView->setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate); ui->group_graphicsView->show();