[PyQt] [PyQt4.3.3] QTabWidget empty because of QSplitter().saveState() and QSplitter().restoreState()

alteo_gange romanocaldoni at free.fr
Mon May 19 18:49:39 BST 2008


Hi,
when i start the following script:

--------------------------------------------------
#!/usr/bin/python
# -*- coding: Utf-8 -*-

import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *

class Window(QMainWindow):
	def __init__(self, parent=None):
		QMainWindow.__init__(self)
		tab = QTabWidget()
		self.splitList = []
		for i in range(4):
			split = QSplitter(Qt.Horizontal)
			self.splitList.append(split)
			for j in range(2):
				label = QLabel("label "+str(i)+'_'+str(j))
				split.addWidget(label)
			tab.addTab(split, '')
		self.setCentralWidget(tab)
		
		settings = QSettings()
		for i, j in enumerate(self.splitList):
			j.restoreState(settings.value("split_"+str(i)).toByteArray())

	def closeEvent(self, event):
		if QMessageBox.question(self, "","Do you want save the split's positions?",
			QMessageBox.Yes, QMessageBox.No)==QMessageBox.Yes:
			settings = QSettings()
			for i, j in enumerate(self.splitList):
				settings.setValue("split_"+str(i), QVariant(j.saveState()))

if __name__ == "__main__":
	app = QApplication(sys.argv)
	app.setOrganizationName("Software")
	app.setApplicationName("Software")
	main = Window()
	main.show()
	sys.exit(app.exec_())
-----------------------------------------------------------

... with the following content of file configuration 
($HOME/.config/Software/Software.conf on linux):

-----------------------------------------------------------
[General]
split_0=@ByteArray(\0\0\0\xff\0\0\0\0\0\0\0\x2\0\0\0\0\0\0\0\0\x1\0\0\0\x6\x1\0\0\0\x1)
split_1=@ByteArray(\0\0\0\xff\0\0\0\0\0\0\0\x2\0\0\0\0\0\0\0\0\x1\0\0\0\x6\x1\0\0\0\x1)
split_2=@ByteArray(\0\0\0\xff\0\0\0\0\0\0\0\x2\0\0\0\0\0\0\0\0\x1\0\0\0\x6\x1\0\0\0\x1)
split_3=@ByteArray(\0\0\0\xff\0\0\0\0\0\0\0\x2\0\0\0\0\0\0\0\0\x1\0\0\0\x6\x1\0\0\0\x1)
-----------------------------------------------------------

... the tab are empty. :(

I specify, of course, that my application has already saved these parameter of 
configuration (but it's infrequent).

Have you an idea? 

How test a QByteArray is bugged?

-- 
alteo_gange



More information about the PyQt mailing list