Not able to extract QString from QHash

  • extern QHash<int, QString> StationHash;

    =========Method 1=======
    int var =5
    QHash<int, QString>::iterator i;
    for( i=StationHash.begin(); i != StationHash.end(); i++ )
    QString NextThai = i.key(var);
    ==========Method 2==============
    int var=5;
    QString NextThai= StationHash(5);


    i got an error message for both methods. How to extract Qstring in StationHash
    no matching function for call to QHash <int,QString>:: key(int)

  • Lifetime Qt Champion


    @QString str = myHash.value(5);@

    You hash use an int as key and a QString as value.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.