我写了这样的东西:
class Storage
{
public:
Storage();
QString key() const;
int value() const;
void add_item(QString&,int);
private:
QMap* my_map_;
};
void Storage::add_item(QString& key,int value)//------HERE IS THE SLOT FOR ADDING
{
*my_map_[key] = value;
}
当我试图通过以下方式将项目添加到QMap时:
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_;
};
我收到错误:
error: no matching function for call to 'Storage::add_item(QString, int)
note: candidates are: void Storage::add_item(QString&, int)
我怎么想通过ref发送QString.其他然后我现在这样做?
谢谢.