Skip to content

Support QMainWindow .ui files in load_ui_file#1326

Open
YektaY wants to merge 5 commits intoslaclab:masterfrom
YektaY:YektaY/fix_mainwindow_designer#1321
Open

Support QMainWindow .ui files in load_ui_file#1326
YektaY wants to merge 5 commits intoslaclab:masterfrom
YektaY:YektaY/fix_mainwindow_designer#1321

Conversation

@YektaY
Copy link
Copy Markdown
Collaborator

@YektaY YektaY commented Apr 17, 2026

Detect root widget class from .ui XML and use MainWindowDisplay (QMainWindow-based) when the file defines a QMainWindow, avoiding the AttributeError on setCentralWidget.

Note: not sure this is the best approach or even a good idea to support QMainWindow as a root widget

Fixes #1321

@Hexotical
Copy link
Copy Markdown

I've tested this and it works

@YektaY YektaY requested a review from jbellister-slac April 17, 2026 21:48
YektaY added 3 commits April 18, 2026 09:29
Detect root widget class from .ui XML and use MainWindowDisplay
(QMainWindow-based) when the file defines a QMainWindow, avoiding the
AttributeError on setCentralWidget.

Fixes slaclab#1321
@YektaY YektaY force-pushed the YektaY/fix_mainwindow_designer#1321 branch from 81142e8 to 0ed221e Compare April 18, 2026 16:37
YektaY added 2 commits April 18, 2026 16:18
Extract shared display logic into DisplayBase mixin so both
Display (QWidget) and MainWindowDisplay (QMainWindow) share the
full interface. Update isinstance checks to use DisplayBase so
navigation, menus, and macro propagation work for both types.

Fixes slaclab#1321
@Hexotical
Copy link
Copy Markdown

Hexotical commented Apr 20, 2026

If you try and reload a main window display from the menu, the window doesn't reload

raceback (most recent call last):
File "/sdf/home/l/lujko/venv/lib/python3.12/site-packages/pydm/main_window.py", line 472, in reload_display
args = curr_display.args()
^^^^^^^^^^^^^^^^^
AttributeError: 'MainWindowDisplay' object has no attribute 'args'

This works now, decreasing or increasing font size resets the window size but that's fine

@jbellister-slac
Copy link
Copy Markdown
Collaborator

I think this looks like a reasonable way of doing it since it leaves existing displays alone. Should be good once the reload is cleaned up.

@Hexotical
Copy link
Copy Markdown

tested again, reload works now

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.

MainWindow built entirely in Designer throwing AttributeError

3 participants