diff --git a/src/lib/QtGui/QWidget/index.ts b/src/lib/QtGui/QWidget/index.ts index ed7871324..ddf4b7287 100644 --- a/src/lib/QtGui/QWidget/index.ts +++ b/src/lib/QtGui/QWidget/index.ts @@ -33,9 +33,9 @@ export abstract class NodeWidget extends EventWidget { setMouseTracking = (isMouseTracked: boolean) => { this.native.setMouseTracking(isMouseTracked); }; - setEnabled = (enabled: boolean)=>{ + setEnabled = (enabled: boolean) => { this.native.setEnabled(enabled); - } + }; } export class QWidget extends NodeWidget { diff --git a/src/lib/QtWidgets/QMainWindow/index.ts b/src/lib/QtWidgets/QMainWindow/index.ts index 872cf4ac3..fc6f21b69 100644 --- a/src/lib/QtWidgets/QMainWindow/index.ts +++ b/src/lib/QtWidgets/QMainWindow/index.ts @@ -3,13 +3,14 @@ import { NodeWidget } from "../../QtGui/QWidget"; import { BaseWidgetEvents } from "../../core/EventWidget"; import { FlexNode } from "../../core/YogaWidget"; import { NativeElement } from "../../core/Component"; +import { NodeLayout } from "../QLayout"; export const QMainWindowEvents = Object.freeze({ ...BaseWidgetEvents }); export class QMainWindow extends NodeWidget { native: NativeElement; - protected centralWidget?: NodeWidget; + public centralWidget?: NodeWidget; constructor(parent?: NodeWidget) { let native; if (parent) { @@ -23,8 +24,8 @@ export class QMainWindow extends NodeWidget { // bind member functions this.setCentralWidget.bind(this); this.setFixedSize.bind(this); + this.setLayout = this._setLayout.bind(this); } - setCentralWidget(widget: NodeWidget) { this.centralWidget = widget; this.native.setCentralWidget( @@ -32,6 +33,20 @@ export class QMainWindow extends NodeWidget { widget.getFlexNode() ); } + get layout() { + if (this.centralWidget) { + return this.centralWidget.layout; + } else { + 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); }