OSGViewer in Qt's TabWidget

戏子无情 提交于 2020-01-06 12:28:47

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!