Passare una QLineEdit ad uno SLOT
-
ciao!
ho due bottoni, ed a seconda di quello premuto dovrei riempire una QLineEdit piuttosto che un'altra.
avrei fatto questo SLOT:void DialogAdd::setDir(QLineEdit *txt) { dir = QFileDialog::getExistingDirectory(this, tr("Scegli directory"), QDir::homePath(), QFileDialog::ShowDirsOnly); txt->setText(dir); }poi però ho difficoltà nel connect:
connect(ui->btnSource, &QPushButton::clicked, this, &DialogAdd::setDir(ui->txtSource)); connect(ui->btnDestinazione, &QPushButton::clicked, this, &DialogAdd::setDir(ui->txtDestinazione));in pratica ottengo questo errore:
error: cannot take the address of an rvalue of type 'void' error: lvalue required as unary ‘&’ operand connect(ui->btnSource, &QPushButton::clicked, this, &DialogAdd::setDir(ui->txtSource)); ^come dovrei fare??
-
connect(ui->btnSource, &QPushButton::clicked, this, std::bind(&DialogAdd::setDir,this,ui->txtSource)); connect(ui->btnDestinazione, &QPushButton::clicked, this, std::bind(&DialogAdd::setDir,this,ui->txtDestinazione));@VRonin said in Passare una QLineEdit ad uno SLOT:
connect(ui->btnSource, &QPushButton::clicked, this, std::bind(&DialogAdd::setDir,this,ui->txtSource)); connect(ui->btnDestinazione, &QPushButton::clicked, this, std::bind(&DialogAdd::setDir,this,ui->txtDestinazione));grazie mille!!