Adds gridlayout removeWidget
This commit is contained in:
parent
b15f59cbf3
commit
8703207b56
@ -9,6 +9,7 @@ Napi::Object QGridLayoutWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
char CLASSNAME[] = "QGridLayout";
|
||||
Napi::Function func = DefineClass(env, CLASSNAME, {
|
||||
InstanceMethod("addWidget", &QGridLayoutWrap::addWidget),
|
||||
InstanceMethod("removeWidget", &QGridLayoutWrap::removeWidget),
|
||||
QLAYOUT_WRAPPED_METHODS_EXPORT_DEFINE(QGridLayoutWrap)
|
||||
});
|
||||
constructor = Napi::Persistent(func);
|
||||
@ -50,3 +51,12 @@ Napi::Value QGridLayoutWrap::addWidget(const Napi::CallbackInfo& info) {
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
Napi::Value QGridLayoutWrap::removeWidget(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
Napi::Object qwidgetObject = info[0].As<Napi::Object>();
|
||||
QWidgetWrap* widget = Napi::ObjectWrap<QWidgetWrap>::Unwrap(qwidgetObject);
|
||||
this->instance->removeWidget(widget->getInternalInstance());
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
@ -18,6 +18,7 @@ class QGridLayoutWrap : public Napi::ObjectWrap<QGridLayoutWrap>{
|
||||
static Napi::FunctionReference constructor;
|
||||
//wrapped methods
|
||||
Napi::Value addWidget(const Napi::CallbackInfo& info);
|
||||
Napi::Value removeWidget(const Napi::CallbackInfo& info);
|
||||
QLAYOUT_WRAPPED_METHODS_DECLARATION
|
||||
};
|
||||
|
||||
|
||||
@ -18,4 +18,8 @@ export class QGridLayout extends NodeLayout {
|
||||
this.native.addWidget(widget.native);
|
||||
this.children.add(widget);
|
||||
};
|
||||
removeWidget = (widget: NodeWidget) => {
|
||||
this.native.removeWidget(widget.native);
|
||||
this.children.delete(widget);
|
||||
};
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user