Adds measuremode to leafnode widgets

This commit is contained in:
Atul R 2019-07-11 23:40:25 +02:00
parent 9fbef26cda
commit 275c4b2d64
5 changed files with 13 additions and 2 deletions

View File

@ -1,3 +1,7 @@
# Common errors
1. Segmentation fault: Segmentation fault occurs when you access a Pointer that is pointing to an invalid memory address. One major reason for this can be that JS garbage collector would have garbage collected the addon generated value and you try accessing it after a while. This is mostly the case if you see seg fault happening randomly after some time of startup.
1. **Segmentation fault:** Segmentation fault occurs when you access a Pointer that is pointing to an invalid memory address. One major reason for this can be that JS garbage collector would have garbage collected the addon generated value and you try accessing it after a while. This is mostly the case if you see seg fault happening randomly after some time of startup.
2. **Widget not visible in Flex layout** Widget might have gotten zero height/width. This can occur if yoga was not able to get the default height/width of the widget. Make sure you have implemented
`YGNodeSetMeasureFunc(this->instance->getFlexNode(), &extrautils::measureQtWidget);`
if its a leaf node widget(doesnt contain any children).

View File

@ -12,7 +12,6 @@ Napi::Object QCheckBoxWrap::init(Napi::Env env, Napi::Object exports) {
Napi::Function func = DefineClass(env, CLASSNAME, {
InstanceMethod("setText", &QCheckBoxWrap::setText),
QWIDGET_WRAPPED_METHODS_EXPORT_DEFINE(QCheckBoxWrap)
QWIDGET_WRAPPED_METHODS_EXPORT_DEFINE(QCheckBoxWrap)
});
constructor = Napi::Persistent(func);
exports.Set(CLASSNAME, func);
@ -36,6 +35,8 @@ QCheckBoxWrap::QCheckBoxWrap(const Napi::CallbackInfo& info): Napi::ObjectWrap<Q
}else {
extrautils::throwTypeError(env, "Wrong number of arguments");
}
// Adds measure function on yoga node so that widget size is calculated based on its text also.
YGNodeSetMeasureFunc(this->instance->getFlexNode(), &extrautils::measureQtWidget);
}
QCheckBoxWrap::~QCheckBoxWrap() {

View File

@ -35,6 +35,8 @@ QLineEditWrap::QLineEditWrap(const Napi::CallbackInfo& info): Napi::ObjectWrap<Q
}else {
extrautils::throwTypeError(env, "Wrong number of arguments");
}
// Adds measure function on yoga node so that widget size is calculated based on its text also.
YGNodeSetMeasureFunc(this->instance->getFlexNode(), &extrautils::measureQtWidget);
}
QLineEditWrap::~QLineEditWrap() {

View File

@ -35,6 +35,8 @@ QProgressBarWrap::QProgressBarWrap(const Napi::CallbackInfo& info): Napi::Object
}else {
extrautils::throwTypeError(env, "Wrong number of arguments");
}
// Adds measure function on yoga node so that widget size is calculated based on its own size.
YGNodeSetMeasureFunc(this->instance->getFlexNode(), &extrautils::measureQtWidget);
}
QProgressBarWrap::~QProgressBarWrap() {

View File

@ -35,6 +35,8 @@ QRadioButtonWrap::QRadioButtonWrap(const Napi::CallbackInfo& info): Napi::Object
}else {
extrautils::throwTypeError(env, "Wrong number of arguments");
}
// Adds measure function on yoga node so that widget size is calculated based on its own size.
YGNodeSetMeasureFunc(this->instance->getFlexNode(), &extrautils::measureQtWidget);
}
QRadioButtonWrap::~QRadioButtonWrap() {