Hi, I wrote something like this:
class Storage
{
public:
Storage();
QString key() const;
int value() const;
void add_item(QString&,int);
private:
QMap<QString,int>* my_map_;
};
void Storage::add_item(QString& key,int value)//------HERE IS THE SLOT FOR ADDING
{
*my_map_[key] = value;
}
and when I'm trying to add item to QMap by:
class Dialog : public QDialog
{
Q_OBJECT
public:
Dialog(QWidget* = 0);
public slots:
void add_item()
{
strg_->add_item(ui->lineEdit->text(),ui->spinBox->value());//---HERE I'M "PASSING" TWO OBJECTS: QString AND int
ui->lineEdit->clear();
}
private:
Ui::Dialog* ui;
Storage* strg_;
};
I'm getting error: 'error: no matching function for call to 'Storage::add_item(QString, int)' 'note: candidates are: void Storage::add_item(QString&, int)'
How am I suppose to send QString by ref. other then I do it now? Thank you.