我將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()窗口小部件。
任何想法?
我已經嘗試過這兩件事。 如果你想在一個示範項目,以測試它,我創建並調升一個上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