Added setFlat for QPushButton widget

This commit is contained in:
Kakul Gupta 2019-08-17 16:25:51 +02:00
parent 151d9842c1
commit 5ca694639f
4 changed files with 18 additions and 0 deletions

View File

@ -27,6 +27,7 @@ lineEdit.setObjectName("editable");
const button = new QPushButton();
button.setText("Push Push Push!");
button.setObjectName("btn");
button.setFlat(true);
const progressbar = new QProgressBar();
progressbar.setValue(6);

View File

@ -9,6 +9,7 @@ Napi::Object QPushButtonWrap::init(Napi::Env env, Napi::Object exports) {
char CLASSNAME[] = "QPushButton";
Napi::Function func = DefineClass(env, CLASSNAME, {
InstanceMethod("setText", &QPushButtonWrap::setText),
InstanceMethod("setFlat", &QPushButtonWrap::setFlat),
QWIDGET_WRAPPED_METHODS_EXPORT_DEFINE(QPushButtonWrap)
});
constructor = Napi::Persistent(func);
@ -52,4 +53,14 @@ Napi::Value QPushButtonWrap::setText(const Napi::CallbackInfo& info) {
return env.Null();
}
Napi::Value QPushButtonWrap::setFlat(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
Napi::Boolean isFlat = info[0].As<Napi::Boolean>();
this->instance->setFlat(isFlat.Value());
return env.Null();
}

View File

@ -18,6 +18,7 @@ class QPushButtonWrap : public Napi::ObjectWrap<QPushButtonWrap> {
static Napi::FunctionReference constructor;
//wrapped methods
Napi::Value setText(const Napi::CallbackInfo& info);
Napi::Value setFlat(const Napi::CallbackInfo& info);
QWIDGET_WRAPPED_METHODS_DECLARATION
};

View File

@ -25,9 +25,14 @@ export class QPushButton extends NodeWidget {
this.native = native;
// bind member functions
this.setText.bind(this);
this.setFlat.bind(this);
}
setText(text: string | number) {
this.native.setText(`${text}`);
}
setFlat(isFlat: boolean) {
this.native.setFlat(isFlat);
}
}