How to set initial size of the main window?

@pieper @lassoan @jcfr

How do I set the initial size and location of the main SlicerQREADS window. A physician complained it comes up too small and I agreed. Any solutions?

Thanks

A physician complained it comes up too small and I agreed. Any solutions?

Last size of application is currently saved in the settings after the application is closed.

How would like to compute the initial size ?

Once you answer that question, it will be possible setting slicer.util.mainWindow().size if it has not already been saved in the settings.

OK, for some reason, mine is not remembering from previous runs. Ok, I will try to look inti that. thanks

I’ve seen this behavior on mac.

If you need a workaround you can also do something like slicer.util.mainWindow().setGeometry(20,20, 500, 500)

Hello @pieper,

That worked as far as being able to set the geometry, but it would be nice if I could, for instance, center it and set the size proportional to the screen geometry.

Thanks

yes, you can query the screen size from slicer.app and do all those calculations. See QGuiApplication Class | Qt GUI 5.15.3 and search for screen for details.

OK, I hope the save-settings thing starts working again. That would be best. This issue was actually mentioned by the chairman of the Apps Oversight Committee after my demo.

@jcfr @pieper

FYI: I won’t need this if it could remember the last geometry upon closing the window. That’s the root of the problem. So, if you could solve that, I’m cool.

For reference, the setting of initial window size related to the SlicerQReads demo is now tracked in issue SlicerQReads#62

I looked a couple times and it’s not instantly obvious. It bugs me but not enough to fix it myself.

For reference that issue regarding remembering window size on macOS is being tracked at Settings save on application exit does not work · Issue #4601 · Slicer/Slicer · GitHub.

That GitHub issue is currently assigned to you @pieper. If you don’t have plans to fix it, I guess you should remove yourself from the issue so that it doesn’t appear you are actively working on it or plan to work on it. I think it was assigned to you being a macOS user.

Thanks for making the link @jamesobutler, I unassigned myself so it’s up for grabs. I could test if someone proposes a fix.

@pieper @jamesobutler @lassoan

Currently, when SlicerQREADS is launched for the first time, it sets the main window to a default size and then upon exiting, it stores the last size so that subsequent launches will bring up the window in in that size. Doctors are complaining about that initial size being too small. Could you please tell me where that initial default size is set?

Thanks

You can use the --settings-path option to find where the settings are installed on your system (Application settings — 3D Slicer documentation) and then you can pre-configure it for uses which ever values you prefer. Compare the files before and after doing your config to decide what to change.

Another option is to change the default in your custom app (search the code for where the main window size is set).

Great!

So the setting is maintained in C:\Users\userID\AppData\Roaming\Mayo Clinic\SlicerQReads.ini

It resides in the [MainWindow] group and looks like this…

geometry=@ByteArray(\x1\xd9\xd0\xcb\0\x3\0\0\0\0\x2\x1d\0\0\x1\b\0\0\x5\x61\0\0\x3\x61\0\0\x2\x1e\0\0\x1'\0\0\x5\0\0\x3\0\0\0\0\0\0\0\0\a\x80\0\0\x2\x1e\0\0\x1'\0\0\x5\0\0\x3)

When I delete it, SlicerQREADS comes up very small. And then when I exit, the geometry parameter is created.

So I did as you said and pre-configured it by …

  1. Launching SlicerQREADS and setting the main window to the desired size, and then exiting
  2. Copying the “geometry=” parameter from SlicerQReads.ini to the installation folder, C:\QREADS_3D_MPR\share\SlicerQReads-4.13\SlicerQReadsDefaultSettings.ini
  3. Deleting the “geometry=” parameter from SlicerQReads.ini
  4. Launched SlicerQREADS again and IT WORKED!!! YES!

So I’m hoping that adding the “geometry=” parameter to my DefaultSettings.ini in my source C:\SlicerQREADS_Source\Applications\SlicerQReadsApp\Resources\Settings folder, will carry over to my build.

Thanks for the tip!

Just curious, @spycolyf what is the new desired initial window size? Upon first launching the Slicer app is it to be fully maximized? Then closing of the app saves the current size to be used in the next subsequent session.

Yes, fully maximized would be great. That would work for different monitor sizes. But, the ideal size would be the size and position of the QREADS app main window that launches SlicerQREADS via DOS command.

Hey @jamesobutler , why did you ask?

Is there an easy way to maximize it on initial launch?