NodeWidget

Abstract class to add functionalities common to all Widgets.

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

NodeWidget 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 widget's easily. Additionally it helps in type checking process. If you wish to create a div like widget use QWidget instead.

*NodeWidget is the base class for all widgets.**

Example

const {
NodeWidget,
QPushButton,
QWidget,
QRadioButton
} = require("@nodegui/nodegui");
// showWidget can accept any widget since it expects NodeWidget
const showWidget = (widget: NodeWidget) => {
widget.show();
};
showWidget(new QPushButton());
showWidget(new QWidget());
showWidget(new QRadioButton());

All Widgets should extend from NodeWidget Implement all native QWidget methods here so that all widgets get access to those aswell

Type parameters

Signals: QWidgetSignals

Hierarchy

YogaWidget‹Signals›

NodeWidget

QWidget

QAbstractScrollArea

QAbstractSlider

QAbstractButton

QAbstractSpinBox

QCalendarWidget

QLabel

NodeDialog

QLineEdit

QMenu

QMenuBar

QMainWindow

QProgressBar

QComboBox

QSpinBox

QStackedWidget

QTabWidget

QGroupBox

Index

Constructors

Properties

Methods

Constructors

constructor

+ new NodeWidget(native: NativeElement): NodeWidget

Inherited from EventWidget.constructor

Overrides Component.constructor

Parameters:

NameType
nativeNativeElement

Returns: NodeWidget

Properties

_rawInlineStyle

_rawInlineStyle: string = ""


Optional layout

layout? : NodeLayout‹Signals›


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 = "widget"

Methods

activateWindow

activateWindow(): void

Returns: void


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


adjustSize

adjustSize(): void

Returns: void


close

close(): boolean

Returns: boolean


font

font(): QFont

Returns: QFont


geometry

geometry(): QRect

Returns: QRect


getFlexNode

getFlexNode(): FlexNode

Inherited from YogaWidget.getFlexNode

Returns: FlexNode


hasMouseTracking

hasMouseTracking(): boolean

Returns: boolean


hide

hide(): void

Returns: void


inherits

inherits(className: string): boolean

Inherited from NodeObject.inherits

Parameters:

NameType
classNamestring

Returns: boolean


isEnabled

isEnabled(): boolean

Returns: boolean


isVisible

isVisible(): boolean

Returns: boolean


lower

lower(): void

Returns: void


move

move(x: number, y: number): void

Parameters:

NameType
xnumber
ynumber

Returns: void


objectName

objectName(): string

Inherited from NodeObject.objectName

Returns: string


pos

pos(): object

Returns: object


property

property(name: string): QVariant

Inherited from NodeObject.property

Parameters:

NameType
namestring

Returns: QVariant


raise

raise(): void

Returns: void


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


repaint

repaint(): void

Returns: void


resize

resize(width: number, height: number): void

Parameters:

NameType
widthnumber
heightnumber

Returns: void


setAttribute

setAttribute(attribute: WidgetAttribute, switchOn: boolean): void

Parameters:

NameType
attributeWidgetAttribute
switchOnboolean

Returns: void


setContextMenuPolicy

setContextMenuPolicy(contextMenuPolicy: ContextMenuPolicy): void

Parameters:

NameType
contextMenuPolicyContextMenuPolicy

Returns: void


setCursor

setCursor(cursor: CursorShape | QCursor): void

Parameters:

NameType
cursorCursorShape | QCursor

Returns: void


setEnabled

setEnabled(enabled: boolean): void

Parameters:

NameType
enabledboolean

Returns: void


setFixedSize

setFixedSize(width: number, height: number): void

Parameters:

NameType
widthnumber
heightnumber

Returns: void


setFlexNodeSizeControlled

setFlexNodeSizeControlled(isSizeControlled: boolean): void

Inherited from YogaWidget.setFlexNodeSizeControlled

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


setFont

setFont(font: QFont): void

Parameters:

NameType
fontQFont

Returns: void


setGeometry

setGeometry(x: number, y: number, w: number, h: number): void

Parameters:

NameType
xnumber
ynumber
wnumber
hnumber

Returns: void


setInlineStyle

setInlineStyle(style: string): void

Parameters:

NameType
stylestring

Returns: void


setLayout

setLayout(parentLayout: NodeLayout‹Signals›): void

Parameters:

NameType
parentLayoutNodeLayout‹Signals›

Returns: void


setMaximumSize

setMaximumSize(maxw: number, maxh: number): void

Parameters:

NameType
maxwnumber
maxhnumber

Returns: void


setMinimumSize

setMinimumSize(minw: number, minh: number): void

Parameters:

NameType
minwnumber
minhnumber

Returns: void


setMouseTracking

setMouseTracking(isMouseTracked: boolean): void

Parameters:

NameType
isMouseTrackedboolean

Returns: void


setNodeParent

setNodeParent(parent?: Component): void

Inherited from Component.setNodeParent

Parameters:

NameType
parent?Component

Returns: void


setObjectName

setObjectName(objectName: string): void

Overrides NodeObject.setObjectName

Parameters:

NameType
objectNamestring

Returns: void


setProperty

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

Inherited from NodeObject.setProperty

Parameters:

NameType
namestring
valueQVariantType

Returns: boolean


setStyleSheet

setStyleSheet(styleSheet: string): void

Parameters:

NameType
styleSheetstring

Returns: void


setWindowFlag

setWindowFlag(windowType: WindowType, switchOn: boolean): void

Parameters:

NameType
windowTypeWindowType
switchOnboolean

Returns: void


setWindowIcon

setWindowIcon(icon: QIcon): void

Parameters:

NameType
iconQIcon

Returns: void


setWindowOpacity

setWindowOpacity(opacity: number): void

Parameters:

NameType
opacitynumber

Returns: void


setWindowState

setWindowState(state: WindowState): void

Parameters:

NameType
stateWindowState

Returns: void


setWindowTitle

setWindowTitle(title: string): void

Parameters:

NameType
titlestring

Returns: void


show

show(): void

Returns: void


showFullScreen

showFullScreen(): void

Returns: void


showMaximized

showMaximized(): void

Returns: void


showMinimized

showMinimized(): void

Returns: void


showNormal

showNormal(): void

Returns: void


size

size(): QSize

Returns: QSize


styleSheet

styleSheet(): string

Returns: string


testAttribute

testAttribute(attribute: WidgetAttribute): boolean

Parameters:

NameType
attributeWidgetAttribute

Returns: boolean


update

update(): void

Returns: void


updateGeometry

updateGeometry(): void

Returns: void


windowOpacity

windowOpacity(): number

Returns: number


windowState

windowState(): number

Returns: number


windowTitle

windowTitle(): string

Returns: string