diff --git a/docs/api/QLineEdit.md b/docs/api/QLineEdit.md index 172046eea..40ec17de7 100644 --- a/docs/api/QLineEdit.md +++ b/docs/api/QLineEdit.md @@ -51,3 +51,9 @@ Sets the given text to the lineEdit's placeholder. #### `lineEdit.text()` Returns the currently set text from native lineEdit widget. + +#### `lineEdit.setReadOnly(isReadOnly)` + +Sets the lineEdit to be read only. lineEdit property holds whether the line edit is read only. + +- `isReadOnly` boolean \ No newline at end of file diff --git a/src/cpp/QtWidgets/QLineEdit/qlineedit_wrap.cpp b/src/cpp/QtWidgets/QLineEdit/qlineedit_wrap.cpp index c0880e7ee..165d7e84a 100644 --- a/src/cpp/QtWidgets/QLineEdit/qlineedit_wrap.cpp +++ b/src/cpp/QtWidgets/QLineEdit/qlineedit_wrap.cpp @@ -14,6 +14,7 @@ Napi::Object QLineEditWrap::init(Napi::Env env, Napi::Object exports) { InstanceMethod("setPlaceholderText", &QLineEditWrap::setPlaceholderText), InstanceMethod("setText", &QLineEditWrap::setText), InstanceMethod("text", &QLineEditWrap::text), + InstanceMethod("setReadOnly", &QLineEditWrap::setReadOnly), QWIDGET_WRAPPED_METHODS_EXPORT_DEFINE(QLineEditWrap) }); constructor = Napi::Persistent(func); @@ -55,6 +56,15 @@ Napi::Value QLineEditWrap::setText(const Napi::CallbackInfo& info) { return env.Null(); } +Napi::Value QLineEditWrap::setReadOnly(const Napi::CallbackInfo &info) +{ + Napi::Env env = info.Env(); + Napi::HandleScope scope(env); + Napi::Boolean isReadOnly = info[0].As(); + this->instance->setReadOnly(isReadOnly.Value()); + return env.Null(); +} + Napi::Value QLineEditWrap::text(const Napi::CallbackInfo& info) { Napi::Env env = info.Env(); Napi::HandleScope scope(env); diff --git a/src/cpp/QtWidgets/QLineEdit/qlineedit_wrap.h b/src/cpp/QtWidgets/QLineEdit/qlineedit_wrap.h index 6330cbe01..4e24fff9b 100644 --- a/src/cpp/QtWidgets/QLineEdit/qlineedit_wrap.h +++ b/src/cpp/QtWidgets/QLineEdit/qlineedit_wrap.h @@ -19,7 +19,8 @@ class QLineEditWrap : public Napi::ObjectWrap{ Napi::Value setText(const Napi::CallbackInfo& info); Napi::Value text(const Napi::CallbackInfo& info); Napi::Value setPlaceholderText(const Napi::CallbackInfo &info); - + Napi::Value setReadOnly(const Napi::CallbackInfo &info); + QWIDGET_WRAPPED_METHODS_DECLARATION }; diff --git a/src/lib/QtWidgets/QLineEdit/index.ts b/src/lib/QtWidgets/QLineEdit/index.ts index 42f28733e..b84f79e88 100644 --- a/src/lib/QtWidgets/QLineEdit/index.ts +++ b/src/lib/QtWidgets/QLineEdit/index.ts @@ -30,6 +30,7 @@ export class QLineEdit extends NodeWidget { this.setText.bind(this); this.text.bind(this); this.setPlaceholderText.bind(this); + this.setReadOnly.bind(this); } setText(text: string) { text && this.native.setText(text); @@ -41,4 +42,7 @@ export class QLineEdit extends NodeWidget { this.placeholderText = text; this.native.setPlaceholderText(text); } + setReadOnly(isReadOnly: boolean) { + this.native.setReadOnly(isReadOnly); + } }