Get string buy its number
Ok i need something like database but small. For examle i have 5 strings which have their own uniq id.
And if request id it must give me a string wich connected with this id.
Somethin like:
list->addVar(1,"blah1');
list->addVar(5,"blah2");
list->requeststring(5); and it returns "blah2"
and if we have added list->addVar(5,"blah2"); one time and then another time like
list->addVar(5,"blah3"); it will replace old "blah2" with new "blah3" string
so what object must i use in this case??
Re: Get string buy its number
Tried QMap<int, QString> or std::map<int, string>?
Re: Get string buy its number
If it is small, then maybe an array would be the way to go!
Re: Get string buy its number
I have read abowt QMap and it is exactly what i want)
But here is a problem:
Code:
void MainWindow
::textChanged(QString textch
) {
//At first we are finding index of our element
int lineidx = tabWidget->currentIndex();
//Then adding item in QMap using lineidx varieble as key and textch as value (maybe i do something wrong because after qDebug()<< linemap.value(index); it returns nothing!
linemap[lineidx]= textch;
}
What wrong??
Re: Get string buy its number
in:
linemap.value(index)
does index exist in the map?
Re: Get string buy its number
Index is an variable which must exist in map if linemap[lineidx]= textch; is right way to add value in map)