diff --git a/src/cpp/include/nodegui/QtWidgets/QWidget/qwidget_macro.h b/src/cpp/include/nodegui/QtWidgets/QWidget/qwidget_macro.h index abcc6c2df..f9924d42e 100644 --- a/src/cpp/include/nodegui/QtWidgets/QWidget/qwidget_macro.h +++ b/src/cpp/include/nodegui/QtWidgets/QWidget/qwidget_macro.h @@ -63,7 +63,11 @@ Napi::HandleScope scope(env); \ Napi::String text = info[0].As(); \ std::string style = text.Utf8Value(); \ - this->instance->setStyleSheet(style.c_str()); \ + QString newStyle = QString::fromStdString(style); \ + QString currentStyleSheet = this->instance->styleSheet(); \ + if (newStyle != currentStyleSheet) { \ + this->instance->setStyleSheet(newStyle); \ + } \ return env.Null(); \ } \ Napi::Value setCursor(const Napi::CallbackInfo& info) { \ diff --git a/src/demo.ts b/src/demo.ts index f7bf19fa9..35a1f4abc 100644 --- a/src/demo.ts +++ b/src/demo.ts @@ -9,6 +9,8 @@ const label = new QLabel(); label.setText('Hello'); const label2 = new QLabel(); label2.setText('LABEL'); +label2.setInlineStyle('color: blue;'); +label2.setInlineStyle('color: teal;'); tab.addTab(label, new QIcon(), 'I am label tab'); tab.addTab(label2, new QIcon(), 'TAB2');