paceholder / nodeeditor

Qt Node Editor. Dataflow programming framework
BSD 3-Clause "New" or "Revised" License
2.92k stars 794 forks source link

Embedded widget with wrong size when content has changed #408

Closed yvanblanchard closed 1 month ago

yvanblanchard commented 5 months ago

Hello,

I have a node with an embedded widget (QtLabel). This Label widget contained a quite long text, and after updating the flow graph, this node was updated and text was shorter. Problem is that the lable widget kept its previous size, instead of being resized as expected. The node (container) of this widget was correctly resized (smaller), but not the widget child..

Before: image

After: image

Any idea ?

mariusalexander commented 4 months ago

Can you try to use a QLayout to manage the size of the label?

QWidget* embeddedWidget() {
    auto* widget = new QWidget;
    auto* lay = new QVBoxLayout; // or QHBoxLayout
    auto* label = new QLabel; // your label
    lay->addWidget(label);
    widget->setLayout(lay);
    return widget;
}
yvanblanchard commented 3 months ago

@mariusalexander thank you, but I had already used layout for my embedded widget. it seems like this issue is possibly related to a Qt bug (related to zooming effect): #121

yvanblanchard commented 1 month ago

...when also using 'embeddedWidgetSizeUpdated' in eventFilter of the widget (Qlabel orother), it works fine!