improv: return the index of the last added tab (#405)
* widgets(tabs): return the index of the last added tab * widgets(tabs): returning the index of the newly added tab * demo: using the tab component in the demo to verify * lint: fixing lint
This commit is contained in:
parent
cf7d241b51
commit
5415fa3576
@ -65,9 +65,10 @@ Napi::Value QTabWidgetWrap::addTab(const Napi::CallbackInfo& info) {
|
||||
Napi::ObjectWrap<QWidgetWrap>::Unwrap(pageObject);
|
||||
QIconWrap* iconWrap = Napi::ObjectWrap<QIconWrap>::Unwrap(iconObject);
|
||||
|
||||
this->instance->addTab(pageObjectWrap->getInternalInstance(),
|
||||
*iconWrap->getInternalInstance(), label.c_str());
|
||||
return env.Null();
|
||||
int index =
|
||||
this->instance->addTab(pageObjectWrap->getInternalInstance(),
|
||||
*iconWrap->getInternalInstance(), label.c_str());
|
||||
return Napi::Number::New(env, index);
|
||||
}
|
||||
|
||||
Napi::Value QTabWidgetWrap::setTabPosition(const Napi::CallbackInfo& info) {
|
||||
|
||||
@ -42,10 +42,11 @@ export class QTabWidget extends NodeWidget<QTabWidgetSignals> {
|
||||
this.native = native;
|
||||
}
|
||||
|
||||
addTab(page: NodeWidget<any>, icon: QIcon, label: string): void {
|
||||
this.native.addTab(page.native, icon.native, label);
|
||||
addTab(page: NodeWidget<any>, icon: QIcon, label: string): number {
|
||||
const index = this.native.addTab(page.native, icon.native, label);
|
||||
this.tabs.push(page);
|
||||
page.setFlexNodeSizeControlled(true);
|
||||
return index;
|
||||
}
|
||||
|
||||
setTabPosition(tabPosition: TabPosition): void {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user