在 QTabWidget (PyQT) 中添加删除的选项卡
我遇到了 pyQT 的问题。 所以我用设计器创建了一个图形界面,包含一个 QTabWidget。 问题是我想在函数运行时隐藏和显示选项卡。我找到了一种解决方案,即删除所有选项卡并稍后添加它们。 假设我只有两个选项卡:
removedTab = self._application.getAlgorithmGUI().getWidget('tabWidget_Verification').widget(1)
self._application.getAlgorithmGUI().getWidget( 'tabWidget_Verification' ).removeTab( 1 )
当我稍后尝试添加这个已删除的选项卡时,我的程序崩溃了。
self._application.getAlgorithmGUI().getWidget( 'tabWidget_Verification' ).addTab(removedTab,QString.fromUtf8("TabRemoved"))
这是我的错误消息:
QCoreApplication::sendPostedEvents: Cannot send posted events for objects in another thread
QCoreApplication::sendPostedEvents: Cannot send posted events for objects in another thread
QCoreApplication::sendPostedEvents: Cannot send posted events for objects in another thread
QCoreApplication::sendPostedEvents: Cannot send posted events for objects in another thread
<unknown>: Fatal IO error 11 (Ressource temporairement non disponible) on X server :0.0.
有什么建议吗?
I'm facing an issue with pyQT.
So I created a graphical interface with designer, containing a QTabWidget.
The things is I would like to hide and show tabs when my function is running. I found one solution that consists in removing all the tabs and adding them later.
Lets say I only have two tabs :
removedTab = self._application.getAlgorithmGUI().getWidget('tabWidget_Verification').widget(1)
self._application.getAlgorithmGUI().getWidget( 'tabWidget_Verification' ).removeTab( 1 )
And when I try later to add this removed tab, my program crashes.
self._application.getAlgorithmGUI().getWidget( 'tabWidget_Verification' ).addTab(removedTab,QString.fromUtf8("TabRemoved"))
This is my error message :
QCoreApplication::sendPostedEvents: Cannot send posted events for objects in another thread
QCoreApplication::sendPostedEvents: Cannot send posted events for objects in another thread
QCoreApplication::sendPostedEvents: Cannot send posted events for objects in another thread
QCoreApplication::sendPostedEvents: Cannot send posted events for objects in another thread
<unknown>: Fatal IO error 11 (Ressource temporairement non disponible) on X server :0.0.
Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在主窗口对象或您拥有的任何小部件中声明所需的所有选项卡:
例如:
即使您尚未调用
addTab()
方法,您也可以正常将小部件分配给您的选项卡。例如:
只要有必要,您就可以显示您的选项卡。
例如:
以同样的方式,您也可以再次将其从索引号中删除。
例如:
同一个选项卡可以根据需要多次调用。
我认为这种方式非常干净和简单。
如果这不符合您的需求,请告诉我。
You can declare all the tabs you need in your mainwindow object or whatever widget you have:
Ex.:
And you can assign the widgets to your tabs normally even if you didn't call the
addTab()
method yet.Ex.:
Whenever it is necessary, you can show your tab.
Ex.:
And on the same way, you can also remove it again, from its index number.
Ex.:
The same tab can be called again as many times as you want.
I think this way is quite clean and simple.
If this doesn't fit in your needs please let me know.