2

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.

Beachwalker
  • 7,685
  • 6
  • 52
  • 94
  • 1
    osgEearth uses OpenGL right? If I remember correctly QMdiArea has some issues with OpenGL widgets. Don't take my word for it though as I might be wrong. – Daniel Hedberg Jul 21 '13 at 19:16

2 Answers2

1

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.

Community
  • 1
  • 1
Beachwalker
  • 7,685
  • 6
  • 52
  • 94
  • Hello Thomas, I am new in osgearth and qt. I want create a qt app and show osgearth view in main window, but I cant! my problem is integration between qt window and osgearth window. can you help me? – Ahmad Sarabian Dec 11 '16 at 08:01
1

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

stefan
  • 10,215
  • 4
  • 49
  • 90