QGridLayout

The QGridLayout class lays out widgets in a grid.

This class is a JS wrapper around Qt's QGridLayout

Example

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

Hierarchy

NodeLayoutQGridLayoutSignals

QGridLayout

Index

Constructors

Properties

Methods

Constructors

constructor

+ new QGridLayout(): QGridLayout

Overrides EventWidget.constructor

Returns: QGridLayout

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

Overrides EventWidget.constructor

Parameters:

NameType
parentNodeWidget‹any›

Returns: QGridLayout

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

Inherited from EventWidget.addEventListener

Type parameters:

SignalType: keyof QGridLayoutSignals

Parameters:

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


addLayout

addLayout(layout: NodeLayout‹any›, row: number, column: number, rowSpan: number, columnSpan: number, alignment: AlignmentFlag): void

Parameters:

NameTypeDefault
layoutNodeLayout‹any›-
rownumber-
columnnumber-
rowSpannumber1
columnSpannumber1
alignmentAlignmentFlagAlignmentFlag.AlignLeft

Returns: void


addWidget

addWidget(widget: NodeWidget‹any›, row: number, col: number, rowSpan: number, colSpan: number): void

Overrides NodeLayout.addWidget

Parameters:

NameTypeDefault
widgetNodeWidget‹any›-
rownumber0
colnumber0
rowSpannumber1
colSpannumber1

Returns: void


columnCount

columnCount(): number

Returns: number


columnMinimumWidth

columnMinimumWidth(column: number): number

Parameters:

NameType
columnnumber

Returns: number


columnStretch

columnStretch(column: number): number

Parameters:

NameType
columnnumber

Returns: number


dumpObjectInfo

dumpObjectInfo(): void

Inherited from NodeObject.dumpObjectInfo

Returns: void


dumpObjectTree

dumpObjectTree(): void

Inherited from NodeObject.dumpObjectTree

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.


horizontalSpacing

horizontalSpacing(): number

Returns: number


inherits

inherits(className: string): boolean

Inherited from NodeObject.inherits

Parameters:

NameType
classNamestring

Returns: boolean


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

Inherited from EventWidget.removeEventListener

Type parameters:

SignalType: keyof QGridLayoutSignals

Parameters:

NameType
signalTypeSignalType
callbackQGridLayoutSignals[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(widget: NodeWidget‹any›): void

Overrides NodeLayout.removeWidget

Parameters:

NameType
widgetNodeWidget‹any›

Returns: void


rowCount

rowCount(): number

Returns: number


rowMinimumHeight

rowMinimumHeight(row: number): number

Parameters:

NameType
rownumber

Returns: number


rowStretch

rowStretch(row: number): number

Parameters:

NameType
rownumber

Returns: number


setColumnMinimumWidth

setColumnMinimumWidth(column: number, minSize: number): void

Parameters:

NameType
columnnumber
minSizenumber

Returns: void


setColumnStretch

setColumnStretch(column: number, stretch: number): void

Parameters:

NameType
columnnumber
stretchnumber

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


setHorizontalSpacing

setHorizontalSpacing(spacing: number): void

Parameters:

NameType
spacingnumber

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


setRowMinimumHeight

setRowMinimumHeight(row: number, minSize: number): void

Parameters:

NameType
rownumber
minSizenumber

Returns: void


setRowStretch

setRowStretch(row: number, stretch: number): void

Parameters:

NameType
rownumber
stretchnumber

Returns: void


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


setVerticalSpacing

setVerticalSpacing(spacing: number): void

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


verticalSpacing

verticalSpacing(): number

Returns: number