[PyQt] Combobox with Multiple Columns

David Boddie david at boddie.org.uk
Tue May 19 21:36:35 BST 2015


On Mon, 18 May 2015 20:28:59 -0700, Willem Buitendyk wrote:

> Newbie here.
> 
> I’m trying to find information on populating a QComobox with multiple
> columns from a datasource.  I can currently populate using: 
> 
> setModelColumn(self.model.fieldIndex(“some_field_name”))
> 
> I would like to have the combobox display two columns for each row but only
> return the value in the first column.

You should be able to replace the view with a QTableView using the
QComboBox's setView() method. You will probably have to configure it to
show things exactly the way you want them.

As to only getting values from the first column, I'm not sure how the view
affects this so it may just work with the setModelColumn() call you used
but I've not tried this.

David


More information about the PyQt mailing list