Fix for setLayout on mainwindow

This commit is contained in:
Atul R 2019-07-14 00:41:52 +02:00
parent 63685c88c4
commit 85af0c209a
2 changed files with 9 additions and 9 deletions

View File

@ -16,6 +16,7 @@ FlexLayout::NodeContext *FlexLayout::getNodeContext(YGNodeRef node)
FlexLayout::FlexLayout(QWidget *parentWidget, YGNodeRef parentNode): QLayout(parentWidget)
{
// spdlog::set_level(spdlog::level::off);
this->node = parentNode;
}

View File

@ -1,7 +1,6 @@
import addon from "../../core/addon";
import { NodeWidget } from "../../QtGui/QWidget";
import { BaseWidgetEvents } from "../../core/EventWidget";
import { FlexNode } from "../../core/YogaWidget";
import { NativeElement } from "../../core/Component";
import { NodeLayout } from "../QLayout";
@ -24,7 +23,14 @@ export class QMainWindow extends NodeWidget {
// bind member functions
this.setCentralWidget.bind(this);
this.setFixedSize.bind(this);
this.setLayout = this._setLayout.bind(this);
this.setLayout = (parentLayout: NodeLayout) => {
if (this.centralWidget) {
this.centralWidget.setLayout(parentLayout);
} else {
this.native.setLayout(parentLayout.native);
super.layout = parentLayout;
}
};
}
setCentralWidget(widget: NodeWidget) {
this.centralWidget = widget;
@ -40,13 +46,6 @@ export class QMainWindow extends NodeWidget {
return super.layout;
}
}
private _setLayout(parentLayout: NodeLayout) {
if (this.centralWidget) {
return this.centralWidget.setLayout(parentLayout);
} else {
return super.setLayout(parentLayout);
}
}
setFixedSize(width: number, height: number) {
this.native.setFixedSize(width, height);
}