Question

Is there something special about putting osgEarth's ViewerViewer into a QMdiArea? I created a QMdiArea as central Widget (called setCentralWidget) instead of taking osgEarth's viewer directly as central widget.

QMdiArea *mdiArea = new QMdiArea(this); 
setCentralWidget(mdiArea); // call to QMainWindows method, snippet is taken from app's MainWindow 
mdiArea->addSubWindow(viewerWidget); // this doesn't work, globe is not drawn

Everything I tried didn't worked... except osgEarth's ViewerWidget is set as central widget of my MainWindow. Also tried MultiViewerWidget without any success but because I need only one view the ViewerWidget should be ok, or not?

I had a look into the examples but didn't succed to use one of them as starting point.

Any hints? Thank's in advance.

Was it helpful?

Solution 2

Try setting the subwindow's geometry before starting the UI.

   QMdiSubWindow* sw = mdiArea->addSubWindow(viewerWidget); 
   sw->setGeometry(...); 

Otherwise OSG will probably become confused.

Got this answer by Gwaldron in the osgEarth forum here and it worked.

Also setting a minimum size for the viewerWidget will help (e.g. for positioning on TabWidget). See my question and answer here.

OTHER TIPS

you can try this, where Form1 is a QDialog

in main.cpp

int main()
{
    QApplication a(argc, argv);
    Form1 w=new Form1();//qdialog
    .................//do something to initial the map
    w.loadWidget(viewerWidget);
    w.show();//the order of the loadwiget() and show() is important!!!!!
    a.exec(); 
}

in Form1.cpp

void Form1::loadWidget(QWidget *qwidget)
{
    qwidget->setMinimumSize( ui.mdiArea->width(),ui.mdiArea->height());
    QMdiSubWindow * subW=ui.mdiArea->addSubWindow(qwidget);
    subW->setWindowFlags(Qt::SubWindow | Qt::FramelessWindowHint);
    subW->maximumSize();
}

This works well with qt 4.8.4+osgearth 2.3

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top