YogaWidget

Abstract class to add common functionality related to Flex layout to all Widgets.

*This class implements methods related to flex layout required to be present in all widgets**

YogaWidget is an abstract class and hence no instances of the same should be created. It exists so that we can add similar functionalities related to flex layout to all widget's easily. We implement flex layout using a library called Yoga. As part of yoga every widget needs to store its own flex properties such as alignItems, flexDirection etc. This is done with the help of YogaWidget.

const { QWidget } = require("@nodegui/nodegui");
const view = new QWidget();
// getFlexNode is a method from YogaWidget
const flexNode = view.getFlexNode();

YogaWidget helps in storing all flex properties of a widget.

Type parameters

Signals: QObjectSignals

Hierarchy

NodeObject‹Signals›

YogaWidget

NodeWidget

Index

Constructors

Properties

Methods

Constructors

constructor

+ new YogaWidget(native: NativeElement): YogaWidget

Inherited from EventWidget.constructor

Overrides Component.constructor

Parameters:

NameType
nativeNativeElement

Returns: YogaWidget

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

Methods

addEventListener

addEventListener<SignalType>(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


getFlexNode

getFlexNode(): FlexNode

Returns: FlexNode


inherits

inherits(className: string): boolean

Inherited from NodeObject.inherits

Parameters:

NameType
classNamestring

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

removeEventListener<SignalType>(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


setFlexNodeSizeControlled

setFlexNodeSizeControlled(isSizeControlled: boolean): void

sets whether the widget's size is controlled by someone else (for example a window's size is controlled by its frame when dragged).

Parameters:

NameTypeDescription
isSizeControlledboolean

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