问题
I am using OpenSceneGraph 3.0.1 and having a problem with the Qt integration using the
osgQt::GLWidget
when adding it to a tab control during startup (inside the constructor of my main window.
MainWindow::MainWindow(QWidget* parent)
: QMainWindow(parent), ui(new Ui::MainWindow)
{
ui->setupUi(this);
QWidget* viewerWidget = new MyViewerWidget(new osgViewer::Viewer());
ui->tabWidget->addTab(viewerWidget, "My Osg View");
// tab entry was added but nothing to see than empty Osg Window
}
It works, when calling the code from a menu after displaying the main window:
void gcdrp::MainWindow::on_actionCreate_Simulation_View_triggered()
{
QWidget* viewerWidget = new MyViewerWidget(new osgViewer::Viewer());
ui->tabWidget->addTab(viewerWidget, "My Osg View");
// tab with content is visible (as expected)
}
It seems like the scene graph is screwed up. Any ideas?
回答1:
Works with setMinimumSize:
QWidget* viewerWidget = new MyViewerWidget(new osgViewer::Viewer());
viewerWidget->setMinimumSize( ui->tabWidget->width(), ui->tabWidget->height());
来源:https://stackoverflow.com/questions/17828411/osgviewer-in-qts-tabwidget