remove unused imports from demo
This commit is contained in:
parent
3c36226b71
commit
b33345bc92
@ -34,16 +34,18 @@ QBoxLayoutWrap::QBoxLayoutWrap(const Napi::CallbackInfo& info)
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
if (info.Length() == 2) {
|
||||
QBoxLayout::Direction dir = static_cast<QBoxLayout::Direction>(info[0].As<Napi::Number>().Int32Value());
|
||||
QBoxLayout::Direction dir = static_cast<QBoxLayout::Direction>(
|
||||
info[0].As<Napi::Number>().Int32Value());
|
||||
Napi::Object parentObject = info[1].As<Napi::Object>();
|
||||
QWidgetWrap* parentWidgetWrap =
|
||||
Napi::ObjectWrap<QWidgetWrap>::Unwrap(parentObject);
|
||||
this->instance = new NBoxLayout(dir, parentWidgetWrap->getInternalInstance());
|
||||
} else if (info.Length() == 1){
|
||||
QBoxLayout::Direction dir = static_cast<QBoxLayout::Direction>(info[0].As<Napi::Number>().Int32Value());
|
||||
this->instance =
|
||||
new NBoxLayout(dir, parentWidgetWrap->getInternalInstance());
|
||||
} else if (info.Length() == 1) {
|
||||
QBoxLayout::Direction dir = static_cast<QBoxLayout::Direction>(
|
||||
info[0].As<Napi::Number>().Int32Value());
|
||||
this->instance = new NBoxLayout(dir);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
Napi::TypeError::New(env, "Wrong number of arguments")
|
||||
.ThrowAsJavaScriptException();
|
||||
}
|
||||
@ -124,7 +126,8 @@ Napi::Value QBoxLayoutWrap::removeWidget(const Napi::CallbackInfo& info) {
|
||||
Napi::Value QBoxLayoutWrap::setDirection(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
QBoxLayout::Direction dir = static_cast<QBoxLayout::Direction>(info[0].As<Napi::Number>().Int32Value());
|
||||
QBoxLayout::Direction dir = static_cast<QBoxLayout::Direction>(
|
||||
info[0].As<Napi::Number>().Int32Value());
|
||||
this->instance->setDirection(dir);
|
||||
return env.Null();
|
||||
}
|
||||
23
src/demo.ts
23
src/demo.ts
@ -1,12 +1,11 @@
|
||||
import { QWidget, QMainWindow, FlexLayout, QLabel, QBoxLayout, QPushButton } from './index';
|
||||
import { QScrollArea } from './lib/QtWidgets/QScrollArea';
|
||||
import { QWidget, QMainWindow, QLabel, QBoxLayout, QPushButton } from './index';
|
||||
import { Direction } from './lib/QtEnums';
|
||||
|
||||
const win = new QMainWindow();
|
||||
const center = new QWidget();
|
||||
const btn1 = new QPushButton();
|
||||
const btn2 = new QPushButton();
|
||||
const boxLayout = new QBoxLayout(Direction.LeftToRight)
|
||||
const boxLayout = new QBoxLayout(Direction.LeftToRight);
|
||||
btn1.setText(`
|
||||
😱😱😱😱😱😱😱😱😱😱😱😱😱😱😱😱😱😱😱
|
||||
Hellloooooo
|
||||
@ -38,22 +37,22 @@ btn2.setInlineStyle(`padding: 10;font-family: "Sans serif";`);
|
||||
center.setLayout(boxLayout);
|
||||
boxLayout.addWidget(btn1);
|
||||
boxLayout.addWidget(btn2);
|
||||
const box2 = new QBoxLayout(Direction.BottomToTop)
|
||||
const box2 = new QBoxLayout(Direction.BottomToTop);
|
||||
const lbl1 = new QLabel();
|
||||
const lbl2 = new QLabel();
|
||||
lbl1.setText("lbl1")
|
||||
lbl2.setText("lbl2")
|
||||
lbl1.setText('lbl1');
|
||||
lbl2.setText('lbl2');
|
||||
lbl1.setInlineStyle(`border: 2px solid blue;`);
|
||||
lbl2.setInlineStyle(`border: 2px solid green;`);
|
||||
box2.addWidget(lbl1);
|
||||
box2.addWidget(lbl2);
|
||||
btn1.addEventListener('clicked', ()=>{
|
||||
console.log('direction',boxLayout.direction())
|
||||
boxLayout.addLayout(box2, 2)
|
||||
})
|
||||
btn2.addEventListener('clicked', ()=>{
|
||||
btn1.addEventListener('clicked', () => {
|
||||
console.log('direction', boxLayout.direction());
|
||||
boxLayout.addLayout(box2, 2);
|
||||
});
|
||||
btn2.addEventListener('clicked', () => {
|
||||
boxLayout.addSpacing(20);
|
||||
} )
|
||||
});
|
||||
win.setCentralWidget(center);
|
||||
win.show();
|
||||
|
||||
|
||||
@ -17,13 +17,13 @@ export class QBoxLayout extends NodeLayout {
|
||||
this.nodeParent = parent;
|
||||
this.native = native;
|
||||
}
|
||||
addLayout(layout: NodeLayout, stretch: number = 0): void {
|
||||
addLayout(layout: NodeLayout, stretch = 0): void {
|
||||
this.native.addLayout(layout.native, stretch);
|
||||
}
|
||||
addSpacing(size: number): void {
|
||||
this.native.addSpacing(size);
|
||||
}
|
||||
addStretch(stretch: number = 0): void {
|
||||
addStretch(stretch = 0): void {
|
||||
this.native.addStretch(stretch);
|
||||
}
|
||||
addStrut(size: number): void {
|
||||
@ -36,7 +36,7 @@ export class QBoxLayout extends NodeLayout {
|
||||
direction(): Direction {
|
||||
return this.native.direction();
|
||||
}
|
||||
insertLayout(index: number, layout: NodeLayout, stretch: number = 0): void {
|
||||
insertLayout(index: number, layout: NodeLayout, stretch = 0): void {
|
||||
this.native.insertLayout(index, layout.native, stretch);
|
||||
}
|
||||
removeWidget(widget: NodeWidget): void {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user