嵌入式QGraphicsView在对话框关闭后不会隐藏
问题描述:
我将QDialog调用为模式,showNormal和showFullscreen。在正常模式下,一切正常。使用Keyevent时,Dialog会按预期关闭。在Fullscreen中,在对话框关闭之后,QGraphicsView将保持在最佳状态。我试过的所有东西(如关闭/更新视图)都失败了。视图位于顶部。嵌入式QGraphicsView在对话框关闭后不会隐藏
view = new QGraphicsView(scene);
view->setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
view->setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
view->setFrameStyle(QFrame::NoFrame);
view->setBackgroundBrush(Qt::white);
view->setRenderHints(QPainter::Antialiasing);
view->setSceneRect(0,0,resolution.x(),resolution.y());
也许我的结构将有助于解决这个问题:
这调用QDialog的命名GraphicsWidgetDialog。
void DemoArrowDialog::setDemo() {
gwd->graphicsWidget->setListenKeyEvents(true);
gwd->setWindowTitle("Demo");
gwd->setFixedSize(500,500);
gwd->restoreGeometry(settings);
gwd->setContentsMargins(0,0,0,0);
gwd->setModal(false);
gwd->showNormal();
gwd->graphicsWidget->show();
gwd->setFocus();
}
void DemoArrowDialog::setFullScreenDemo() {
settings = gwd->saveGeometry();
gwd->graphicsWidget->setListenKeyEvents(true);
gwd->setContentsMargins(0,0,0,0);
gwd->setModal(true);
gwd->graphicsWidget->showFullScreen();
gwd->showFullScreen();
gwd->setFocus();
}
这是GraphicsWidgetDialog
GraphicsWidgetDialog::GraphicsWidgetDialog(QWidget *parent) :
QDialog(parent) {
graphicsWidget = new GraphicsWidget;
QGridLayout *layout = new QGridLayout;
layout->addWidget(graphicsWidget);
layout->setContentsMargins(0,0,0,0);
graphicsWidget->loadConfig();
graphicsWidget->loadArrowConfig("Arrow");
graphicsWidget->setArrowPosition(arrowPosition(arrowCenter));
graphicsWidget->update();
setLayout(layout);
connect(graphicsWidget,SIGNAL(closeEvent()),this,SLOT(reject()));
}
的GraphicsWidget的定义是包含QGraphcisView和场景
在keyPessEvent它会发出的closeEvent()窗口小部件。
任何想法?
答
对不起,自从我写了Qt以来已经有一段时间了..但是也许您需要拨打gwd->setModal(false)
或在关闭对话框之前离开全屏模式?
答
尝试使graphicsWidget成为GraphicsWidgetDialog的子项。
graphicsWidget = new GraphicsWidget(this);
我已经尝试过这两件事。 如果你想在一个示范项目,以测试它,我创建并调升一个上http://files.faunst.com/ – torsten 2010-06-12 11:19:52
这似乎是与QGL SampleBuffers一个问题: 视图 - > setViewport(新QGLWidget来绘图(QGLFormat(QGL :: SampleBuffers))); 如果我评论这一行,它的工作方式与预期的一样,除了我可以使用opengl进行硬件渲染 – torsten 2010-06-21 23:33:13