views:

27

answers:

3

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?

A: 

Sorry, been a while since I've written Qt .. but perhaps you need to call gwd->setModal(false) or leave the fullscreen mode before closing the dialog?

humbagumba
Both things i've allready tried.If you want to test it with on a demo project, i created and upped one on http://files.faunst.com/
torsten
It seems to be a problem with the QGL SampleBuffers:view->setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));If i comment this line, it works like expected, except that i can use opengl for hardware rendering
torsten
A: 

Try making graphicsWidget to be a child of GraphicsWidgetDialog.

graphicsWidget = new GraphicsWidget(this);
Andrew
A: 

Thanks for the reply. I tried this, but no change. I've upped the demoproject on my site, if you like try by yourself.

link text

torsten