Adds size methods to qmainwindow and setText accepts number

This commit is contained in:
Atul R 2019-06-09 08:46:01 +02:00
parent 5fccc207f7
commit ac0a544565
5 changed files with 17 additions and 4 deletions

View File

@ -11,6 +11,7 @@ Napi::Object QMainWindowWrap::init(Napi::Env env, Napi::Object exports) {
QWIDGET_WRAPPED_METHODS_EXPORT_DEFINE(QMainWindowWrap)
YOGAWIDGET_WRAPPED_METHODS_EXPORT_DEFINE(QMainWindowWrap)
InstanceMethod("setCentralWidget",&QMainWindowWrap::setCentralWidget),
InstanceMethod("setFixedSize",&QMainWindowWrap::setFixedSize),
});
constructor = Napi::Persistent(func);
exports.Set(CLASSNAME, func);
@ -53,5 +54,13 @@ Napi::Value QMainWindowWrap::setCentralWidget(const Napi::CallbackInfo& info){
return env.Null();
}
Napi::Value QMainWindowWrap::setFixedSize(const Napi::CallbackInfo& info){
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
int width = info[0].As<Napi::Number>().Int32Value();
int height = info[1].As<Napi::Number>().Int32Value();
this->instance->setFixedSize(width, height);
return env.Null();
}

View File

@ -18,6 +18,7 @@ public:
static Napi::FunctionReference constructor;
//wrapped methods
Napi::Value setCentralWidget(const Napi::CallbackInfo& info);
Napi::Value setFixedSize(const Napi::CallbackInfo& info);
QWIDGET_WRAPPED_METHODS_DECLARATION
YOGAWIDGET_WRAPPED_METHODS_DECLARATION

View File

@ -16,8 +16,8 @@ export class QLabel extends NodeWidget {
setWordWrap(on: boolean) {
this.native.setWordWrap(on);
}
setText(text: string) {
this.native.setText(text);
setText(text: string | number) {
this.native.setText(`${text}`);
}
text() {
return this.native.text();

View File

@ -15,4 +15,7 @@ export class QMainWindow extends NodeWidget {
this.native.setCentralWidget(widget.native);
this.children.add(widget);
}
setFixedSize(width: number, height: number) {
this.native.setFixedSize(width, height);
}
}

View File

@ -23,7 +23,7 @@ export class QPushButton extends SignalNodeWidget {
this.native = native;
}
setText(text: string) {
this.native.setText(text);
setText(text: string | number) {
this.native.setText(`${text}`);
}
}