1

hei guys...i have problem creating dropdown menu on bb10.. let's say i have dropdown A and dropdown B..the option onSelectedIndexChange action on dropdown A will change the option of dropdown B.. here's the code :

RegisterPhone.cpp :

void RegisterPhone::initData(){
JsonDataAccess jda;
QVariantList country = jda.load("app/native/assets/countries.json").toList();
QVariant var;
foreach(var, country){
    QVariantMap a = var.toMap();
    countries.append(a);
    if(a.value("cca3").toString()=="IDN"){
        dropDownCountry->add(Option::create().text(a.value("name").toString()).selected(TRUE));
        QVariantList b = a.value("callingCode").toList();
        codeLabel->setText("+" + b.at(0).toString());
    }else{
        dropDownCountry->add(Option::create().text(a.value("name").toString()));
    }
}
}

void RegisterPhone::initControl() {

connect(buttonReg, SIGNAL(clicked()), this, SLOT(doRegister()));
connect(dropDownCountry, SIGNAL(selectedIndexChanged(int)), this,
                SLOT(onSelectedIndex(int)));
connect(codeDropDown, SIGNAL(selectedOptionChanged(bb::cascades::Option*)), this,
                SLOT(onSelectedValue(bb::cascades::Option*)));

}

void RegisterPhone::onSelectedIndex(int i){
qDebug() << countries.at(i).toMap();
QVariantMap country = countries.at(i).toMap();

QVariantList codes = country.value("callingCode").toList();

int count = codes.count();

qDebug() << codeDropDown;

if(count>1){
    codeDropDown->removeAll();

    isDropDown = true;
    qDebug() << "count lebih dari 1";
    codeLabel->setVisible(false);
    codeDropDown->setVisible(true);
    foreach(QVariant var, codes){
        codeDropDown->add(Option::create().text("+" + var.toString()));
    }
    codeDropDown->setSelectedIndex(0);
}
else{

    isDropDown = false;
    qDebug() << "count == 1";
    codeLabel->setVisible(true);
    codeDropDown->setVisible(false);
    if(codes.at(0).toString()==""){
        codeLabel->setText("");
    }
    else{
        codeLabel->setText("+" + codes.at(0).toString());
    }
}
}

void RegisterPhone::onSelectedValue(bb::cascades::Option* value){
stringCode = value->text();

}

i have no problem creating the UI..it works fine when built and run..but when i choose several times, it would stopped working.. i have found out the problem is when i do

codeDropDown->removeAll()

also when i debug, it stopped here too

void RegisterPhone::onSelectedValue(bb::cascades::Option* value){
stringCode = value->text();

}

i need this function to retrieve the value of the callingCode

i don't know how to fix it..can please somebody help me?

pardon for the bad english... thanks

0 Answers0