This string returns a QString value
ui->lineEdit->text(),ui->spinBox->value()
Therefore, you cannot use it as a modifiable link. However, you can use it as an unmodifiable (constant) link by changing the add_item function to const QString& .
void Storage::add_item(const QString& key,int value) { *my_map_[key] = value; }
In addition, depending on the implementation of QString, it would be quite simple to pass it by value:
void Storage::add_item(QString key,int value) { *my_map_[key] = value; }
... note, however, that it is usually much more efficient to use const references with classes where possible.
source share