diff --git a/src/cpp/include/nodegui/QtWidgets/QAbstractButton/qabstractbutton_macro.h b/src/cpp/include/nodegui/QtWidgets/QAbstractButton/qabstractbutton_macro.h index 089f541ef..1ab44e910 100644 --- a/src/cpp/include/nodegui/QtWidgets/QAbstractButton/qabstractbutton_macro.h +++ b/src/cpp/include/nodegui/QtWidgets/QAbstractButton/qabstractbutton_macro.h @@ -20,7 +20,7 @@ \ Napi::String napiText = info[0].As(); \ std::string text = napiText.Utf8Value(); \ - this->instance->setText(text.c_str()); \ + this->instance->setText(QString::fromUtf8(text.c_str())); \ return env.Null(); \ } \ \ diff --git a/src/cpp/lib/QtWidgets/QLabel/qlabel_wrap.cpp b/src/cpp/lib/QtWidgets/QLabel/qlabel_wrap.cpp index de4ad5b5a..c08ce78c8 100644 --- a/src/cpp/lib/QtWidgets/QLabel/qlabel_wrap.cpp +++ b/src/cpp/lib/QtWidgets/QLabel/qlabel_wrap.cpp @@ -76,7 +76,7 @@ Napi::Value QLabelWrap::setText(const Napi::CallbackInfo& info) { Napi::String text = info[0].As(); std::string label = text.Utf8Value(); - this->instance->setText(label.c_str()); + this->instance->setText(QString::fromUtf8(label.c_str())); return env.Null(); } diff --git a/src/cpp/lib/core/Events/eventwidget.cpp b/src/cpp/lib/core/Events/eventwidget.cpp index ae0a170f5..283bc8418 100644 --- a/src/cpp/lib/core/Events/eventwidget.cpp +++ b/src/cpp/lib/core/Events/eventwidget.cpp @@ -10,9 +10,9 @@ void EventWidget::subscribeToQtEvent(std::string evtString) { this->subscribedEvents.insert( {static_cast(evtType), evtString}); } catch (...) { - qDebug() << "EventWidget: Couldn't subscribe to qt event" - << evtString.c_str() - << ". If this is a signal you can safely ignore this warning"; + // qDebug() << "EventWidget: Couldn't subscribe to qt event" + // << evtString.c_str() + // << ". If this is a signal you can safely ignore this warning"; } } @@ -22,9 +22,9 @@ void EventWidget::unSubscribeToQtEvent(std::string evtString) { this->subscribedEvents.erase( static_cast(evtType)); // erasing by key } catch (...) { - qDebug() << "EventWidget: Couldn't unsubscribe to qt event " - << evtString.c_str() - << ". If this is a signal you can safely ignore this warning "; + // qDebug() << "EventWidget: Couldn't unsubscribe to qt event " + // << evtString.c_str() + // << ". If this is a signal you can safely ignore this warning "; } } diff --git a/src/lib/QtWidgets/QLayout.ts b/src/lib/QtWidgets/QLayout.ts index ab5a357df..d3d7a6854 100644 --- a/src/lib/QtWidgets/QLayout.ts +++ b/src/lib/QtWidgets/QLayout.ts @@ -5,6 +5,7 @@ import { NodeObject } from '../QtCore/QObject'; export abstract class NodeLayout extends NodeObject { type = 'layout'; abstract addWidget(childWidget: NodeWidget, ...args: any[]): void; + abstract removeWidget(childWidget: NodeWidget): void; activate(): boolean { return this.native.activate(); } diff --git a/src/lib/QtWidgets/QScrollArea.ts b/src/lib/QtWidgets/QScrollArea.ts index c4d3b737a..b4808c7c6 100644 --- a/src/lib/QtWidgets/QScrollArea.ts +++ b/src/lib/QtWidgets/QScrollArea.ts @@ -20,6 +20,7 @@ export class QScrollArea extends QAbstractScrollArea { super(native); this.native = native; this.nodeParent = parent; + this.setWidgetResizable(true); } setWidget(widget: NodeWidget): void { // react:✓, //TODO:getter diff --git a/src/lib/core/FlexLayout.ts b/src/lib/core/FlexLayout.ts index bf9165a19..767463bfe 100644 --- a/src/lib/core/FlexLayout.ts +++ b/src/lib/core/FlexLayout.ts @@ -14,6 +14,9 @@ export class FlexLayout extends NodeLayout { protected flexNode?: FlexNode; addWidget(childWidget: NodeWidget, childFlexNode?: FlexNode): void { + if (this.nodeChildren.has(childWidget)) { + return; + } const childYogaNode = childFlexNode || childWidget.getFlexNode(); this.nodeChildren.add(childWidget); this.native.addWidget(childWidget.native, childYogaNode); @@ -25,6 +28,9 @@ export class FlexLayout extends NodeLayout { childFlexNode?: FlexNode, beforeChildFlexNode?: FlexNode, ): void { + if (this.nodeChildren.has(childWidget)) { + return; + } const childYogaNode = childFlexNode || childWidget.getFlexNode(); const beforeChildYogaNode = beforeChildFlexNode || beforeChildWidget.getFlexNode(); this.nodeChildren.add(childWidget); // No orderer required yet, so just inserting at the end. @@ -36,8 +42,8 @@ export class FlexLayout extends NodeLayout { return; } const childYogaNode = childFlexNode || childWidget.getFlexNode(); - this.nodeChildren.delete(childWidget); this.native.removeWidget(childWidget.native, childYogaNode); + this.nodeChildren.delete(childWidget); } setFlexNode(flexNode: FlexNode): void {