[PyKDE] Editable QComboBox in QTable problem ?

david david.f at village.uunet.be
Wed Mar 19 11:49:00 GMT 2003


> > I put an editable QComboBox in a cell of QTable with setCellWidget() :
> >
> > self.combo = QComboBox(self.table)
> > self.combo.setEditable(1)
> > self.table.setCellWidget(line,col,self.combo)
> >
> > When I'm writing in comboBox, the first character is in the comboBox,
> > and after, characters are in a other cell.
> 
> Please provide a small self contained example of your problem.


Hello,

Here is a little example, I'm using PyQt 3.5 and Qt 2.3 :

import sys
from qttable import *
from qt import *


class Form(QDialog):
    def __init__(self,parent = None,name = None,modal = 0,fl = 0):
        QDialog.__init__(self,parent,name,modal,fl)

        self.setProperty('caption',QVariant(self.tr("Form")))
	self.table = QTable(self,'table')
	self.table.setNumRows(4)
	self.table.setNumCols(4)
        combo = QComboBox(self.table)
	combo.setEditable(1)
	combo.insertItem('a')
	combo.insertItem('b')
	combo.insertItem('c')
	self.table.setCellWidget(1,1,combo)

if __name__ == '__main__':
    a = QApplication(sys.argv)
    QObject.connect(a,SIGNAL('lastWindowClosed()'),a,SLOT('quit()'))
    w = Form()
    a.setMainWidget(w)
    w.show()
    a.exec_loop()


Thanks for your help.

David




More information about the PyQt mailing list