简体   繁体   English

如何使用QTabWidget中的osgViewer取消标签页?

[英]How to undock tab with osgViewer from QTabWidget?

I want to undock a QWidget from a QTabWiget (is set as centralWidget). 我想从QTabWiget(设置为centralWidget)中取消QWidget的对接。 The tab contains some Open Scene Graph content (OpenGL Window). 该选项卡包含一些“打开场景图”内容(OpenGL窗口)。 When removing the Tab from the list and putting it into a new Dialog Window (=> undocking from tab) the scene data seems to be corrupt. 当从列表中删除选项卡并将其放入新的对话框窗口(=>从选项卡中取消停靠)时,场景数据似乎已损坏。 It works with "standard widgets" but the osg seems to forget the scene. 它可以与“标准小部件”一起使用,但是OSG似乎忘记了场景。

Surprisingly, undocking works when using a QDockWidget (scene is visible after undocking the window). 出乎意料的是,使用QDockWidget时,取消停靠的工作原理(取消停靠窗口后可以看到场景)。

Anyone knows how to undock a tab without corrupting the osgViewer? 任何人都知道如何在不破坏osgViewer的情况下取消固定选项卡吗?

Code called for to undock from tab and show in new dialog window: 要求从选项卡中取消停靠并显示在新对话框窗口中的代码:

QWidget* gv = // points to an osgViewer in a qt widget 
QDialog* dlg = new QDialog(this); 
dlg->setWindowTitle("hello earth"); 
QHBoxLayout* pMainLay = new QHBoxLayout; 
gv->setMinimumSize(100,100); 
gv->setGeometry(100,100,300,300); 
pMainLay->addWidget(gv); 
dlg->setLayout(pMainLay); 
ui->tabWidget->removeTab(0); // removes the tab at position 0 (docked window)
dlg->show(); // should show the undocked dialog

There is nothing to see in the new dialog. 在新对话框中看不到任何内容。 Did I missed something? 我错过了什么吗? How to "copy" the osg view properly into a new widget/dialog? 如何将osg视图正确“复制”到新的小部件/对话框中? Should I use a composite viewer for this kind of task? 我应该为这种任务使用复合查看器吗? It seems there is not even the empty osg view visible (no blue canvas)... 似乎甚至没有空的osg视图可见(没有蓝色画布)...

It could be that something's going screwy when you add the osgViewer to another widget before removing it from the QTabWidget. 当您将osgViewer添加到另一个小部件, 然后再将其从QTabWidget删除时,可能有些麻烦。 Changing the order might help. 更改顺序可能会有所帮助。

QWidget* gv = // points to an osgViewer in a qt widget 
ui->tabWidget->removeTab(0); // removes the tab at position 0 (docked window)
QDialog* dlg = new QDialog(this); 
dlg->setWindowTitle("hello earth"); 
QHBoxLayout* pMainLay = new QHBoxLayout; 
pMainLay->addWidget(gv); 
dlg->setLayout(pMainLay); 
dlg->show(); // should show the undocked dialog

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM