Embedded QGraphicsView do not hide after Dialog closes
- by torsten
I call a QDialog in to modes, showNormal and showFullscreen. In normal mode all works fine. With a Keyevent the Dialog closes as expected. In Fullscreen, after a keyevent the Dialog closes, but the QGraphicsView will stay on top. All things i've tried (like closing/updating the view) failed. the View sta on top.
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());
Maybe my structure will help to solve the Problem:
This call the QDialog named 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();
}
This is the Definition of the 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()));
}
The GraphicsWidget is the Widget that contains the QGraphcisView and Scene
On keyPessEvent it will emit the closeEvent().
Any Idea?