PDA

View Full Version : Qcombobox and model/item based question



yaguis
4th June 2010, 02:33
Good to all, I'm new to Qt4 and I have 2 questions
1-adraft 3 Qcombobox (country, province, town) to be charged based on the select from the parent. As the data is in three tables in the database want to use the ide SQLQuerymodel is right or should I use Qabstracitemview? someone could show me a basic example how do that.

2 - When should you use models? serious as the number of records to determine model or item

Thanks for everything

tbscope
4th June 2010, 05:36
1-adraft 3 Qcombobox (country, province, town) to be charged based on the select from the parent. As the data is in three tables in the database want to use the ide SQLQuerymodel is right or should I use Qabstracitemview? someone could show me a basic example how do that.
Look at QDataWidgetMapper, it contains some example code.
Here's another example: http://doc.qt.nokia.com/4.6/itemviews-combowidgetmapper.html
And another: http://doc.qt.nokia.com/4.6/itemviews-simplewidgetmapper.html


2 - When should you use models? serious as the number of records to determine model or item
Whenever you can, as much as possible, always. This means, always try to use models and only use the convenience widgets to show a very simple list.

yaguis
4th June 2010, 14:06
thanks for your answer,but that work with data not filtered..i think.. i need that the combos go filtering for his parent this is the table structure

country:
id
country

providence
id
providence
idcountry

person.
id
name
idcountry
idprovidence

when i setup the relation and push the combo providence its populate with all providence, and i need that populate with only the providence of his country parent

Thanks

yaguis
5th June 2010, 12:44
nobody solution? thanks

tbscope
5th June 2010, 12:53
Create 3 models. One for the country, one for the province and one for the person.
When you select a country in the first combo, update the select statement of the second and third combo.
Etc...

yaguis
7th June 2010, 01:22
Create 3 models. One for the country, one for the province and one for the person.
When you select a country in the first combo, update the select statement of the second and third combo.
Etc...


thanks soo much!