Documentation/Nightly/Developers/Style Guide/UI

From Slicer Wiki
Revision as of 18:50, 25 October 2021 by Lasso (talk | contribs) (Updated outdated links in General guidelines.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Home < Documentation < Nightly < Developers < Style Guide < UI

For the latest Slicer documentation, visit the read-the-docs.

General guidelines



Volume Rendering sections

A section is used in a panel to categorize parameters by visually grouping them. In the Volume Rendering module, there are 3 sections: 'Inputs', 'Display', and 'Advanced...'. By default, the 'Inputs' and 'Advanced...' sections are collapsed. This reduces visual cluttering by hiding advanced and rarely used parameters. Sections should be organized in such a way that the workflow takes the user from top to bottom:

  1. The 'Inputs' section is first as it controls the inputs of the volume rendering.
  2. then the 'Display' section controls important display properties
  3. finally, if the previous parameters are not enough to obtain the desired result, the Advanced.. section offers fine tuning of the volume rendering.

Please note that the Advanced-ness of a section doesn't necessarily impacts its position in the section ordering. To create a section you must use a ctkCollapsibleButton [1] with no panel frame. Typically, the main node selector (Volume: in Volume Rendering) is the first GUI element and is outside any section.


Justify elements in panel

Elements in panels should be justified (use of a QFormLayout can simplify the task)


  1. Capitalize the first letter in any text specified for a label or button:
    "Load volumes" instead of "Load Volumes"
    More capitalization rules
  2. Try to use brief phrases when specifying text for a label or button rather than using sentences or sentence fragments ( use "Load volumes" instead of "Choose a volume to load")
  3. Provide fully descriptive tool tips with each widget defined
  4. Don't use colon after each parameter labels:
    "Load volumes" instead of "Load volumes:"
  5. Use US English and avoid abbreviations (see the Naming section above.)


  1. Use the default values for the margins or 0. Default margins are automatically controlled by the Slicer custom style (see QStyle::PM_LayoutLeftMargin)
  2. The minimum size hint of the top level module widget is used to determine the minimum width of the module. The minimum width of a module must not be larger than 500px (subject to change). This is enforced by the automatic test qSlicerMY_MODULE_NAMEModuleGenericTest. If the width is too large, you have multiple ways of narrowing the module panel:
    1. In Qt Designer, you can ensure the sizing is correct by changing the QLayout::SizeConstraint to QLayout::SetMinimumSize. When you preview the module (Ctrl-R), it appears with the same size as it would in Slicer.
    2. Ideally the minimum size hint of each wide GUI element should be fixed, it is unlikely that a large size hint is "ideal".
    3. Alternatively, you might want to investigate the following:
      1. Consider setting the horizontal size policy of such element to QSizePolicy::Ignored
      2. If the element is in a form layout, QFormLayout::layoutFieldGrowthPolicy might need to be set to AllNonFixedFieldsGrow.
      3. All those changes can be set from Qt Designer.