From 286521293772fc5e88b53c838e96f9dae08ebc3d Mon Sep 17 00:00:00 2001 From: Simon Edwards Date: Sun, 6 Feb 2022 19:09:27 +0100 Subject: [PATCH] Add `QWidget.winId()`, useful for forcing window creation --- src/cpp/include/nodegui/QtWidgets/QWidget/qwidget_macro.h | 8 +++++++- src/lib/QtWidgets/QWidget.ts | 4 +++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/cpp/include/nodegui/QtWidgets/QWidget/qwidget_macro.h b/src/cpp/include/nodegui/QtWidgets/QWidget/qwidget_macro.h index 99dd5c81e..13bd0f449 100644 --- a/src/cpp/include/nodegui/QtWidgets/QWidget/qwidget_macro.h +++ b/src/cpp/include/nodegui/QtWidgets/QWidget/qwidget_macro.h @@ -533,6 +533,11 @@ int w = info[0].As().Int32Value(); \ int result = this->instance->heightForWidth(w); \ return Napi::Number::New(env, result); \ + } \ + Napi::Value winId(const Napi::CallbackInfo& info) { \ + Napi::Env env = info.Env(); \ + int result = this->instance->winId(); \ + return Napi::Number::New(env, result); \ } #endif // QWIDGET_WRAPPED_METHODS_DECLARATION @@ -621,7 +626,8 @@ &WidgetWrapName::unsetLayoutDirection), \ InstanceMethod("unsetLocale", &WidgetWrapName::unsetLocale), \ InstanceMethod("windowRole", &WidgetWrapName::windowRole), \ - InstanceMethod("heightForWidth", &WidgetWrapName::heightForWidth), + InstanceMethod("heightForWidth", &WidgetWrapName::heightForWidth), \ + InstanceMethod("winId", &WidgetWrapName::winId), #endif // QWIDGET_WRAPPED_METHODS_EXPORT_DEFINE diff --git a/src/lib/QtWidgets/QWidget.ts b/src/lib/QtWidgets/QWidget.ts index 89398cb49..2a8fb1055 100644 --- a/src/lib/QtWidgets/QWidget.ts +++ b/src/lib/QtWidgets/QWidget.ts @@ -538,7 +538,9 @@ export abstract class NodeWidget extends YogaWid width(): number { return this.property('width').toInt(); } - // TODO: WId winId() const + winId(): number { + return this.native.winId(); + } // TODO: QWidget * window() const windowFilePath(): string { return this.property('windowFilePath').toString();