mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-30 23:27:22 +00:00
Add the ability to read/write boolean properties in the qt_viewer example
This commit is contained in:
parent
f01ac8fc39
commit
e9924f0f76
1 changed files with 18 additions and 0 deletions
|
@ -97,6 +97,10 @@ int main(int argc, char **argv)
|
|||
ui.prop_value->setText(QString::number(*val->to_number()));
|
||||
break;
|
||||
|
||||
case slint::interpreter::Value::Type::Bool:
|
||||
ui.prop_value->setText(*val->to_number() ? "true" : "false");
|
||||
break;
|
||||
|
||||
default:
|
||||
ui.prop_value->clear();
|
||||
break;
|
||||
|
@ -124,6 +128,20 @@ int main(int argc, char **argv)
|
|||
}
|
||||
break;
|
||||
}
|
||||
case slint::interpreter::Value::Type::Bool: {
|
||||
if (ui.prop_value->text() == "true") {
|
||||
val = true;
|
||||
} else if (ui.prop_value->text() == "false") {
|
||||
val = false;
|
||||
} else {
|
||||
QMessageBox::critical(
|
||||
&main, QApplication::translate("qt_viewer", "Set Property Error"),
|
||||
QApplication::translate("qt_viewer", "Invalid conversion to boolean, must be true or false"),
|
||||
QMessageBox::StandardButton::Ok);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
QMessageBox::critical(
|
||||
&main, QApplication::translate("qt_viewer", "Set Property Error"),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue