Make QTabBar.setTabButton() accept null
This commit is contained in:
parent
4c5ccadfc7
commit
7d8fb77481
@ -169,12 +169,18 @@ Napi::Value QTabBarWrap::setTabButton(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
int index = info[0].As<Napi::Number>().Int32Value();
|
||||
int position = info[1].As<Napi::Number>().Int32Value();
|
||||
Napi::Object widgetObject = info[2].As<Napi::Object>();
|
||||
NodeWidgetWrap* widgetWrap =
|
||||
Napi::ObjectWrap<NodeWidgetWrap>::Unwrap(widgetObject);
|
||||
this->instance->setTabButton(index,
|
||||
static_cast<QTabBar::ButtonPosition>(position),
|
||||
widgetWrap->getInternalInstance());
|
||||
|
||||
if (info[2].IsNull()) {
|
||||
this->instance->setTabButton(
|
||||
index, static_cast<QTabBar::ButtonPosition>(position), nullptr);
|
||||
} else {
|
||||
Napi::Object widgetObject = info[2].As<Napi::Object>();
|
||||
NodeWidgetWrap* widgetWrap =
|
||||
Napi::ObjectWrap<NodeWidgetWrap>::Unwrap(widgetObject);
|
||||
this->instance->setTabButton(index,
|
||||
static_cast<QTabBar::ButtonPosition>(position),
|
||||
widgetWrap->getInternalInstance());
|
||||
}
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
|
||||
@ -10,7 +10,7 @@ import { QPoint } from '../QtCore/QPoint';
|
||||
import { QRect } from '../QtCore/QRect';
|
||||
|
||||
/**
|
||||
|
||||
|
||||
> Create and control tabbar.
|
||||
|
||||
* **This class is a JS wrapper around Qt's [QTabBar class](https://doc.qt.io/qt-5/qtabbar.html)**
|
||||
@ -155,8 +155,8 @@ export class QTabBar extends NodeWidget<QTabBarSignals> {
|
||||
removeTab(index: number): void {
|
||||
this.native.removeTab(index);
|
||||
}
|
||||
setTabButton(index: number, position: ButtonPosition, widget: NodeWidget<any>): void {
|
||||
this.native.setTabButton(index, position, widget.native);
|
||||
setTabButton(index: number, position: ButtonPosition, widget: NodeWidget<any> | undefined | null): void {
|
||||
this.native.setTabButton(index, position, widget == null ? null : widget?.native);
|
||||
}
|
||||
setTabData(index: number, data: QVariant): void {
|
||||
this.native.setTabData(index, data.native);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user