diff --git a/src/cpp/include/nodegui/QtWidgets/QHeaderView/nheaderview.hpp b/src/cpp/include/nodegui/QtWidgets/QHeaderView/nheaderview.hpp index b1a4e75ac..750a33495 100644 --- a/src/cpp/include/nodegui/QtWidgets/QHeaderView/nheaderview.hpp +++ b/src/cpp/include/nodegui/QtWidgets/QHeaderView/nheaderview.hpp @@ -12,5 +12,13 @@ class DLL_EXPORT NHeaderView : public QHeaderView, public NodeWidget { public: using QHeaderView::QHeaderView; - virtual void connectSignalsToEventEmitter() { QABSTRACTITEMVIEW_SIGNALS } + virtual void connectSignalsToEventEmitter(){QABSTRACTITEMVIEW_SIGNALS} + + QModelIndex _protected_indexAt(const QPoint &p) const { + return indexAt(p); + } + + void _protected_scrollTo(const QModelIndex &index, ScrollHint hint) { + scrollTo(index, hint); + } }; diff --git a/src/cpp/include/nodegui/QtWidgets/QHeaderView/qheaderview_wrap.h b/src/cpp/include/nodegui/QtWidgets/QHeaderView/qheaderview_wrap.h index 422d8b89a..ed9eb623e 100644 --- a/src/cpp/include/nodegui/QtWidgets/QHeaderView/qheaderview_wrap.h +++ b/src/cpp/include/nodegui/QtWidgets/QHeaderView/qheaderview_wrap.h @@ -17,22 +17,32 @@ class DLL_EXPORT QHeaderViewWrap : public Napi::ObjectWrap { QPointWrap* pointWrap = Napi::ObjectWrap::Unwrap(info[0].As()); QPoint* point = pointWrap->getInternalInstance(); - QModelIndex result = this->instance->QAbstractItemView::indexAt(*point); - auto resultInstance = QModelIndexWrap::constructor.New( - {Napi::External::New(env, new QModelIndex(result))}); - return resultInstance; + + NHeaderView* wrapper = dynamic_cast(this->instance.data()); + if (wrapper) { + QModelIndex result = wrapper->_protected_indexAt(*point); + auto resultInstance = QModelIndexWrap::constructor.New( + {Napi::External::New(env, new QModelIndex(result))}); + return resultInstance; + } else { + return env.Null(); + } } Napi::Value scrollTo(const Napi::CallbackInfo& info) { Napi::Env env = info.Env(); Napi::HandleScope scope(env); - QModelIndexWrap* indexWrap = - Napi::ObjectWrap::Unwrap(info[0].As()); - QModelIndex* index = indexWrap->getInternalInstance(); - QAbstractItemView::ScrollHint hint = - static_cast( - info[1].As().Int32Value()); - this->instance->QAbstractItemView::scrollTo(*index, hint); + + NHeaderView* wrapper = dynamic_cast(this->instance.data()); + if (wrapper) { + QModelIndexWrap* indexWrap = + Napi::ObjectWrap::Unwrap(info[0].As()); + QModelIndex* index = indexWrap->getInternalInstance(); + QAbstractItemView::ScrollHint hint = + static_cast( + info[1].As().Int32Value()); + wrapper->_protected_scrollTo(*index, hint); + } return env.Null(); } diff --git a/src/cpp/lib/QtWidgets/QHeaderView/qheaderview_wrap.cpp b/src/cpp/lib/QtWidgets/QHeaderView/qheaderview_wrap.cpp index 097466dcc..43f614775 100644 --- a/src/cpp/lib/QtWidgets/QHeaderView/qheaderview_wrap.cpp +++ b/src/cpp/lib/QtWidgets/QHeaderView/qheaderview_wrap.cpp @@ -28,7 +28,7 @@ QHeaderViewWrap::QHeaderViewWrap(const Napi::CallbackInfo& info) Napi::Env env = info.Env(); Napi::HandleScope scope(env); - int len = info.Length(); + size_t len = info.Length(); this->disableDeletion = false; if (len == 1) {