xaverxn
25th October 2010, 21:30
Hi,
I have the same problem as
http://www.qtcentre.org/threads/10504-QFileDialog
Too bad the solution doesn't seem to work for me.
I just want to add a widget to a QFileDialog. I tried many things like creating a QFileDialog instance and maniplulating it or its layout, to no effect. Now I even tried subclassing/inheriting and it doesn't give me an error, but changes nothing too:
class myofd(QtGui.QFileDialog):
def __init__(self,parent=None):
super(myofd, self).__init__(parent)
print "Columns: ",self.layout().columnCount()
print "Rows: ",self.layout().rowCount()
print "At 3-0: ",self.layout().itemAtPosition(3,0)
self.layout().removeItem(self.layout().itemAtPosit ion(3,0))
cmbo = QtGui.QComboBox()
cmbo.addItem("MyChoice1")
cmbo.addItem("MyChoice2")
self.layout().addWidget(cmbo,4,0)
self.layout().update()
self.layout().activate()
print "Columns: ",self.layout().columnCount()
print "Rows: ",self.layout().rowCount()
print "At 4-0: ",self.layout().itemAtPosition(4,0)
myloadinst = myofd()
myloadinst.getOpenFileName(self,"Open log file ...","","")
The row count goes up, the ".itemAtPosition" function works, no errors are thrown... only the dialog doesn't contain the new widget.
I've also tried the QLayout functions addChildWidget and addLayout and many more... also QFileDialog methods... sometimes I get a Runtime error:
self.layout().addChildWidget(cmbo)
RuntimeError: no access to protected functions or signals for objects not created from Python
which makes me think there may be some sip/c++/qt protection mechanisms which I don't know.
Am I doing sth wrong? Is there a better way to do this? I hope I don't have to make a file dialog from scratch because QFileDialog is somehow immutable...
Regards,
Xaver
I have the same problem as
http://www.qtcentre.org/threads/10504-QFileDialog
Too bad the solution doesn't seem to work for me.
I just want to add a widget to a QFileDialog. I tried many things like creating a QFileDialog instance and maniplulating it or its layout, to no effect. Now I even tried subclassing/inheriting and it doesn't give me an error, but changes nothing too:
class myofd(QtGui.QFileDialog):
def __init__(self,parent=None):
super(myofd, self).__init__(parent)
print "Columns: ",self.layout().columnCount()
print "Rows: ",self.layout().rowCount()
print "At 3-0: ",self.layout().itemAtPosition(3,0)
self.layout().removeItem(self.layout().itemAtPosit ion(3,0))
cmbo = QtGui.QComboBox()
cmbo.addItem("MyChoice1")
cmbo.addItem("MyChoice2")
self.layout().addWidget(cmbo,4,0)
self.layout().update()
self.layout().activate()
print "Columns: ",self.layout().columnCount()
print "Rows: ",self.layout().rowCount()
print "At 4-0: ",self.layout().itemAtPosition(4,0)
myloadinst = myofd()
myloadinst.getOpenFileName(self,"Open log file ...","","")
The row count goes up, the ".itemAtPosition" function works, no errors are thrown... only the dialog doesn't contain the new widget.
I've also tried the QLayout functions addChildWidget and addLayout and many more... also QFileDialog methods... sometimes I get a Runtime error:
self.layout().addChildWidget(cmbo)
RuntimeError: no access to protected functions or signals for objects not created from Python
which makes me think there may be some sip/c++/qt protection mechanisms which I don't know.
Am I doing sth wrong? Is there a better way to do this? I hope I don't have to make a file dialog from scratch because QFileDialog is somehow immutable...
Regards,
Xaver