NodeLayout

Abstract class to add functionalities common to all Layout.

*This class implements all methods, properties of Qt's QLayout class so that it can be inherited by all layouts**

NodeLayout is an abstract class and hence no instances of the same should be created. It exists so that we can add similar functionalities to all layout's easily. Additionally it helps in typechecking process.

Example

const {
NodeLayout,
NodeWidget,
FlexLayout,
GridLayout,
QPushButton,
QWidget
} = require("@nodegui/nodegui");
// addChildToLayout can accept any layout since it expects NodeLayout
const addChildToLayout = (layout: NodeLayout, widget: NodeWidget) => {
layout.addWidget(widget);
};
addChildToLayout(new FlexLayout(), new QPushButton());
addChildToLayout(new GridLayout(), new QWidget());

Type parameters

Signals: QLayoutSignals

Hierarchy

NodeObject‹Signals›

NodeLayout

FlexLayout

QBoxLayout

QGridLayout

Index

Constructors

Properties

Methods

Constructors

constructor

+ new NodeLayout(native: NativeElement): NodeLayout

Inherited from EventWidget.constructor

Overrides Component.constructor

Parameters:

NameType
nativeNativeElement

Returns: NodeLayout

Properties

Abstract native

native: NativeElement

Inherited from Component.native


nodeChildren

nodeChildren: Set‹Component

Inherited from Component.nodeChildren


Optional nodeParent

nodeParent? : Component

Inherited from Component.nodeParent


type

type: string = "layout"

Methods

activate

activate(): boolean

Returns: boolean


addEventListener

addEventListenerSignalType›(signalType: SignalType, callback: Signals[SignalType]): void

Inherited from EventWidget.addEventListener

Type parameters:

SignalType: keyof Signals

Parameters:

NameTypeDescription
signalTypeSignalTypeSignalType is a signal from the widgets signals interface.
callbackSignals[SignalType]Corresponding callback for the signal as mentioned in the widget's signal interface

Returns: void

void

For example in the case of QPushButton:

const button = new QPushButton();
button.addEventListener('clicked',(checked)=>console.log("clicked"));
// here clicked is a value from QPushButtonSignals interface

addEventListener(eventType: WidgetEventTypes, callback: function): void

Inherited from EventWidget.addEventListener

Parameters:

eventType: WidgetEventTypes

callback: function

For example in the case of QPushButton:

const button = new QPushButton();
button.addEventListener(WidgetEventTypes.HoverEnter,()=>console.log("hovered"));

▸ (event?: NativeRawPointer‹"QEvent"›): void

Parameters:

NameType
event?NativeRawPointer‹"QEvent"›

Returns: void


Abstract addWidget

addWidget(childWidget: NodeWidget‹any›, ...args: any[]): void

Parameters:

NameType
childWidgetNodeWidget‹any›
...argsany[]

Returns: void


inherits

inherits(className: string): boolean

Inherited from NodeObject.inherits

Parameters:

NameType
classNamestring

Returns: boolean


invalidate

invalidate(): void

Returns: void


isEnabled

isEnabled(): boolean

Returns: boolean


objectName

objectName(): string

Inherited from NodeObject.objectName

Returns: string


property

property(name: string): QVariant

Inherited from NodeObject.property

Parameters:

NameType
namestring

Returns: QVariant


removeEventListener

removeEventListenerSignalType›(signalType: SignalType, callback: Signals[SignalType]): void

Inherited from EventWidget.removeEventListener

Type parameters:

SignalType: keyof Signals

Parameters:

NameType
signalTypeSignalType
callbackSignals[SignalType]

Returns: void

removeEventListener(eventType: WidgetEventTypes, callback: function): void

Inherited from EventWidget.removeEventListener

Parameters:

eventType: WidgetEventTypes

callback: function

▸ (event?: NativeRawPointer‹"QEvent"›): void

Parameters:

NameType
event?NativeRawPointer‹"QEvent"›

Returns: void


Abstract removeWidget

removeWidget(childWidget: NodeWidget‹any›): void

Parameters:

NameType
childWidgetNodeWidget‹any›

Returns: void


setContentsMargins

setContentsMargins(left: number, top: number, right: number, bottom: number): void

Parameters:

NameType
leftnumber
topnumber
rightnumber
bottomnumber

Returns: void


setEnabled

setEnabled(enable: boolean): void

Parameters:

NameType
enableboolean

Returns: void


setNodeParent

setNodeParent(parent?: Component): void

Inherited from Component.setNodeParent

Parameters:

NameType
parent?Component

Returns: void


setObjectName

setObjectName(objectName: string): void

Inherited from NodeObject.setObjectName

Parameters:

NameType
objectNamestring

Returns: void


setProperty

setProperty(name: string, value: QVariantType): boolean

Inherited from NodeObject.setProperty

Parameters:

NameType
namestring
valueQVariantType

Returns: boolean


setSizeConstraint

setSizeConstraint(constraint: SizeConstraint): void

Parameters:

NameType
constraintSizeConstraint

Returns: void


setSpacing

setSpacing(spacing: number): void

Parameters:

NameType
spacingnumber

Returns: void


sizeConstraint

sizeConstraint(): SizeConstraint

Returns: SizeConstraint


spacing

spacing(): number

Returns: number


update

update(): void

Returns: void