Malek Samet
Malek Samet

Reputation: 83

reference to type 'const QVariant' could not bind to an rvalue of type 'void'

I am trying to save the following modification : to enable the pushButton_4.

void Vessels::SaveSettings()
{
    QSettings setting("My_vessels","My_selected_vessels");
    setting.beginGroup("Vessels");
    setting.setValue("selected",ui->pushButton_4->setEnabled(false));
    setting.endGroup();
}

When I run, I get this error: vessels.cpp:838:33: error: reference to type 'const QVariant' could not bind to an rvalue of type 'void' qsettings.h:167:55: note: passing argument to parameter 'value' here

All what I wanna know, is how to setvalue for an object from this window. I mean enabling the button is just an example.

Upvotes: 2

Views: 940

Answers (1)

dydil
dydil

Reputation: 1007

setting.setValue("selected",ui->pushButton_4->setEnabled(false));

QWidget::setEnabled returns void, which you can't convert to a QVariant in QSettings::setValue. Did you mean ui->pushButton_4->isEnabled()?

Upvotes: 3

Related Questions