Skip to content

Conversation

@Trighap52
Copy link

@Trighap52 Trighap52 commented Feb 12, 2026

Summary

  • switch Qt table headers to Interactive mode with a minimum section size so users can resize columns
  • keep equal auto-fit sizing until a user manually resizes, then preserve manual widths across source changes and layout updates
  • reset auto-fit when columns are inserted/removed so new column layouts remain sane
  • add a capability-gated testbed test for column resizing and expose resize support in the Qt table probe
  • add a changelog note for Add support for column resizing in Qt tables #4109

Closes #4109.

Validation

  • uv run --python 3.12 --with ruff ruff check qt/src/toga_qt/widgets/table.py qt/tests_backend/widgets/table.py testbed/tests/widgets/test_table.py
  • python3 -m compileall qt/src/toga_qt/widgets/table.py qt/tests_backend/widgets/table.py testbed/tests/widgets/test_table.py
  • QT_QPA_PLATFORM=offscreen uv run --python 3.12 --with ./travertino --with ./core --with ./qt --with PySide6-Essentials~=6.10.0 python script to verify:
    • manual column resize works
    • manual width persists after change_source()
    • manual width persists after subsequent set_bounds()

PR Checklist:

  • All new features have been tested
  • All new features have been documented
  • I have read the CONTRIBUTING.md file
  • I will abide by the code of conduct

Copy link
Contributor

@johnzhou721 johnzhou721 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, and welcome to BeeWare! (Disclaimer that I'm not an official core team member.)

My thoughts on this is that the implementation is looking great -- however -- could you explain how you came to the decision to stop preserving column widths once the user resizes? I'm just curious as to where you came to this decision; for me, I'd personally prefer preserving user proportions of columns when the layout changes -- but that's kind of bikesheddy, and may not be worthy of too much discussion

That said, some small notes inline.

@@ -0,0 +1 @@
Qt Table columns can now be resized by users, and manual column widths are preserved when the table source changes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be 4109.misc.md because Qt table hasn't been in a relase yet.

supports_icons = 2 # All columns
supports_keyboard_shortcuts = False
supports_widgets = False
supports_column_resize = True
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a flag isn't neccesary for this; implementing a probe method resize_column for all backends should be better, with pytest.skip representing platforms that hasn't implemented this yet.

(resize_column should be added and the test should be ran on all platforms; if we find that column resizing does not work, we could skip tests in this PR.)

# A subsequent layout/bounds update should also preserve manual widths.
widget._impl.set_bounds(0, 0, probe.width + 40, probe.height)
await probe.redraw("Table bounds updated")
assert probe.column_width(0) == pytest.approx(resized_width, abs=8)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming we do go with the design you came up with, should we also test that not doing any resize will preserve proportions in layout?

assert probe.column_width(0) == pytest.approx(resized_width, abs=8)

# A subsequent layout/bounds update should also preserve manual widths.
widget._impl.set_bounds(0, 0, probe.width + 40, probe.height)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is kind of fragile; we should do something like setting an explicit width as part of the layout specificaiton on widget, like widget.width = 400.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for column resizing in Qt tables

2 participants