views:

46

answers:

2

hi!

I have two comboboxes:

The first one is Language (English, Italian, French...) and the second one is another list of stuff that is different for every language (or a little bit different) so the content must be loaded every time the language is changed.

How can I handle it?

Example:

If I select English, in the second combobox I have: Red/Purple/Black If I change to Greek, I have: Red/Purple or Red/Pink...

I am using Qt Designer, and I have two Comboboxes with all the possible Items in both of them.

Regards.

A: 

Yes, it is possible. My recommendation would be to go one of two ways.

1) Split the second combo box's items into many combo boxes, each on their own page of a stacked widget. Change the page of the stacked widget that is visible based on the selection of the first combo box.

2) Split the second combo box's items into many models, and set the appropriate model on the second combo box based on the selection of the first combo box.

If you want to get fancier and have the space for it in your UI, you could also consider putting all of the data into one tree model and using a QColumnView.

Caleb Huitt - cjhuitt
A: 

Well, finally I did what I wanted.

Here the code:

void reloadItems()
{
    QString currentLanguage;
    currentLanguage=ui.ownLangComboBox->currentText();

    if (currentLanguage=="English")
    {
        ui.ownGendComboBox->clear();
            ui.ownGendComboBox->addItem("Male");
            ui.ownGendComboBox->addItem("Female");
    }

}

andofor