Skip to content

Commit 368e8ad

Browse files
committed
fix: auto-resize CanvasItem when widget preferred height changes
Made-with: Cursor
1 parent 3972c04 commit 368e8ad

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

app/designer/canvas_item.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,21 @@ def set_property(self, name: str, value: Any):
373373
if hasattr(self._inner_widget, "load_from_props"):
374374
self._inner_widget.load_from_props(self.properties)
375375
return
376+
377+
layout = self._inner_widget.layout()
378+
old_hint_h = layout.sizeHint().height() if layout else -1
379+
376380
apply_property(self._inner_widget, self.type_name, name, value)
381+
382+
if layout:
383+
layout.activate()
384+
new_hint_h = layout.sizeHint().height()
385+
if old_hint_h > 0 and new_hint_h > 0 and abs(new_hint_h - old_hint_h) > 5:
386+
meta = registry.get(self.type_name)
387+
min_h = meta.min_height if meta else MIN_SIZE
388+
r = self.rect()
389+
self.set_rect(QRectF(0, 0, r.width(), max(min_h, new_hint_h)))
390+
377391
if self.is_container() and name in ("spacing", "direction", "currentTab", "layout"):
378392
self.relayout_children()
379393

0 commit comments

Comments
 (0)