Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
) => {
const button = new QPushButton();
button.setText(label);
button.setObjectName(`btn${value}`);
button.addEventListener(QPushButtonEvents.clicked, () => {
onBtnClick(value, type);
});
return {
ui: button,
value,
type
};
};
// Main Window
const win = new QMainWindow();
win.setFixedSize(230, 300);
// Root view
const rootView = new QWidget();
win.addEventListener(
BaseWidgetEvents.KeyRelease,
(nativeEvent: NativeElement) => {
const keyEvt = new QKeyEvent(nativeEvent);
const text = keyEvt.text();
const isNotNumber = isNaN(parseInt(text));
onBtnClick(text, isNotNumber ? "command" : "value");
}
);
rootView.setObjectName("rootView"); //This is like ids in web world
win.setCentralWidget(rootView);
const rootStyleSheet = `
import {
QKeySequence,
QApplication,
QMainWindow,
QMenu,
QIcon,
QSystemTrayIcon,
QAction
} from "@nodegui/nodegui";
import path from "path";
import { Dock } from "@nodegui/nodegui-os-utils";
const icon = require("../assets/nodegui_white.png");
const win = new QMainWindow();
const trayIcon = new QIcon(path.resolve(__dirname, icon));
const tray = new QSystemTrayIcon();
tray.setIcon(trayIcon);
tray.show();
tray.setToolTip("hello");
const menu = new QMenu();
tray.setContextMenu(menu);
// -------------------
// Quit Action
// -------------------
const quitAction = new QAction();
quitAction.setText("Quit");
quitAction.setIcon(trayIcon);
quitAction.addEventListener("triggered", () => {
constructor() {
this.window = new QMainWindow();
this.centralWidget = new QWidget();
this.centralWidget.setObjectName('myroot');
}
}
import { QMainWindow, QWidget, QLabel, FlexLayout } from "@nodegui/nodegui";
const win = new QMainWindow();
win.setWindowTitle("Hello World");
const centralWidget = new QWidget();
centralWidget.setObjectName("myroot");
const rootLayout = new FlexLayout();
centralWidget.setLayout(rootLayout);
const label = new QLabel();
label.setObjectName("mylabel");
label.setText("Hello");
const label2 = new QLabel();
label2.setText("World");
label2.setInlineStyle(`
color: red;
`);