[PyQt] Combobox with Multiple Columns
willem at pcfish.ca
Tue May 19 22:33:34 BST 2015
I actually just figured this out before lunch and have it working as you suggest with QTableView. In my case, I’ve just set the query so that the first field is the one I want the value from. Works very well. I also hide the horizontal and vertical header for a cleaner look.
> On May 19, 2015, at 1:36 PM, David Boddie <david at boddie.org.uk> wrote:
> 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:
>> 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.
> PyQt mailing list PyQt at riverbankcomputing.com
More information about the PyQt