pyside - QTabBar.setTabButton() inside subclass crashes the Application -


in following python snippet, application crashed when run it. tested on mac os x, windows , ubuntu:

import sys pyside.qtcore import * pyside.qtgui import *  class tabbedwindow(qtabwidget):      def __init__(self):         super(tabbedwindow, self).__init__()         self.setwindowtitle(u"tabs test")         self.resize(800, 600)          self.addtab(qtextedit(), "tab 1")         self.addtab(qcalendarwidget(), "tab 2")          self.settabsclosable(true)          tabbar = self.tabbar()         menubutton = qpushbutton('')         menubutton.resize(0,0)         tabbar.settabbutton(1, qtabbar.rightside, menubutton)   def main():     app = qapplication(sys.argv)     window = qmainwindow()     tabs = tabbedwindow()     window.setcentralwidget(tabs)     window.show()     sys.exit(app.exec_())   if __name__ == '__main__':     main() 

when remove line tabbar.settabbutton(1, qtabbar.rightside, menubutton) works!

also, if moved line main function: works too! mean when added main function:

tabbar = tabs.tabbar() menubutton = qpushbutton('') menubutton.resize(0,0) tabbar.settabbutton(1, qtabbar.rightside, menubutton) 

what want hiding close button on tabs.

is there workaround perform this?

finally, found answer make work!

you have declare button member of class.

self.menubutton = qpushbutton('') 

instead of

menubutton = qpushbutton('') 

i hope find solution useful.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -