FlexLayout

Custom layout to help layout child widgets using flex layout.

This class is a JS wrapper around custom Qt layout implemented using Yoga

A FlexLayout can be used to layout all child NodeGui widgets using flex.

Example

const { FlexLayout, QWidget, QLabel } = require("@nodegui/nodegui");
const view = new QWidget();
const layout = new FlexLayout();
view.setLayout(layout);
const label = new QLabel();
label.setText("label1");
const label2 = new QLabel();
label2.setText("label2");
layout.addWidget(label);
layout.addWidget(label2);

Hierarchy

NodeLayoutFlexLayoutSignals

FlexLayout

Index

Constructors

Properties

Methods

Constructors

constructor

+ new FlexLayout(): FlexLayout

Overrides EventWidget.constructor

Returns: FlexLayout

+ new FlexLayout(parent: NodeWidget‹any›): FlexLayout

Overrides EventWidget.constructor

Parameters:

NameType
parentNodeWidget‹any›

Returns: FlexLayout

Properties

native

native: NativeElement

Overrides Component.native


nodeChildren

nodeChildren: Set‹Component

Inherited from Component.nodeChildren


Optional nodeParent

nodeParent? : Component

Inherited from Component.nodeParent


type

type: string = "layout"

Inherited from NodeLayout.type

Methods

activate

activate(): boolean

Inherited from NodeLayout.activate

Returns: boolean


addEventListener

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

Inherited from EventWidget.addEventListener

Type parameters:

SignalType: keyof FlexLayoutSignals

Parameters:

NameTypeDescription
signalTypeSignalTypeSignalType is a signal from the widgets signals interface.
callbackFlexLayoutSignals[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


addWidget

addWidget(childWidget: NodeWidget‹any›, childFlexNode?: FlexNode): void

Overrides NodeLayout.addWidget

Parameters:

NameType
childWidgetNodeWidget‹any›
childFlexNode?FlexNode

Returns: void


eventProcessed

eventProcessed(): boolean

Inherited from EventWidget.eventProcessed

Get the state of the event processed flag

See setEventProcessed().

Returns: boolean

boolean True if the current event is flagged as processed.


getChildIndex

getChildIndex(childWidget: NodeWidget‹any›): number

Parameters:

NameType
childWidgetNodeWidget‹any›

Returns: number


getNextSibling

getNextSibling(childWidget: NodeWidget‹any›): NodeWidget‹any› | null

Parameters:

NameType
childWidgetNodeWidget‹any›

Returns: NodeWidget‹any› | null


inherits

inherits(className: string): boolean

Inherited from NodeObject.inherits

Parameters:

NameType
classNamestring

Returns: boolean


insertChildBefore

insertChildBefore(childWidget: NodeWidget‹any›, beforeChildWidget: NodeWidget‹any›, childFlexNode?: FlexNode, beforeChildFlexNode?: FlexNode): void

Parameters:

NameType
childWidgetNodeWidget‹any›
beforeChildWidgetNodeWidget‹any›
childFlexNode?FlexNode
beforeChildFlexNode?FlexNode

Returns: void


invalidate

invalidate(): void

Inherited from NodeLayout.invalidate

Returns: void


isEnabled

isEnabled(): boolean

Inherited from NodeLayout.isEnabled

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: FlexLayoutSignals[SignalType]): void

Inherited from EventWidget.removeEventListener

Type parameters:

SignalType: keyof FlexLayoutSignals

Parameters:

NameType
signalTypeSignalType
callbackFlexLayoutSignals[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


removeWidget

removeWidget(childWidget: NodeWidget‹any›, childFlexNode?: FlexNode): void

Overrides NodeLayout.removeWidget

Parameters:

NameType
childWidgetNodeWidget‹any›
childFlexNode?FlexNode

Returns: void


setContentsMargins

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

Inherited from NodeLayout.setContentsMargins

Parameters:

NameType
leftnumber
topnumber
rightnumber
bottomnumber

Returns: void


setEnabled

setEnabled(enable: boolean): void

Inherited from NodeLayout.setEnabled

Parameters:

NameType
enableboolean

Returns: void


setEventProcessed

setEventProcessed(isProcessed: boolean): void

Inherited from EventWidget.setEventProcessed

Mark the current event as having been processed

This method is used to indicate that the currently dispatched event has been processed and no further processing by superclasses is required. It only makes sense to call this method from an event handler.

When set, this flag will cause NodeGui's QObject::event() method to return true and not call the superclass event(), effectively preventing any further processing on this event.

Parameters:

NameTypeDescription
isProcessedbooleantrue if the event has been processed.

Returns: void


setFlexNode

setFlexNode(flexNode: FlexNode): void

Parameters:

NameType
flexNodeFlexNode

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

Inherited from NodeLayout.setSizeConstraint

Parameters:

NameType
constraintSizeConstraint

Returns: void


setSpacing

setSpacing(spacing: number): void

Inherited from NodeLayout.setSpacing

Parameters:

NameType
spacingnumber

Returns: void


sizeConstraint

sizeConstraint(): SizeConstraint

Inherited from NodeLayout.sizeConstraint

Returns: SizeConstraint


spacing

spacing(): number

Inherited from NodeLayout.spacing

Returns: number


update

update(): void

Inherited from NodeLayout.update

Returns: void