• Skip to main content
  • Skip to header right navigation
  • Skip to site footer
CDP Studio logo

CDP Studio

The no-code and full-code software development tool for distributed control systems and HMI

  • Doc
  • Why CDP
    • Software developers
    • Automation engineers
    • Managers
  • Products
    • Automation Designer
    • HMI Designer
    • CDP Linux
  • Services
  • Use cases
  • Pricing
  • Try CDP

CDP Studio Documentation

  • GUI - Design & Widgets
  • ReportContainer

ReportContainer Class

The Report Container is a container widget for composing exportable report pages from existing HMI widgets. More...

Header: #include <ReportContainer>
Inherits: CDPBaseWidget
  • List of all members, including inherited members

Properties

  • dateTimeFormat : QString
  • dateTimeUtc : bool
  • fileNamePostfix : QString
  • fileNamePrefix : QString
  • lastSavedFilePath : const QString
  • lockedTheme : QString
  • saveFolder : QString
  • 6 properties inherited from CDPBaseWidget

Public Functions

ReportContainer(QWidget *parent = 0)
virtual ~ReportContainer()
QString dateTimeFormat() const
bool dateTimeUtc() const
QString fileNamePostfix() const
QString fileNamePrefix() const
QString lastSavedFilePath() const
QString lockedTheme() const
QString saveFolder() const
  • 8 public functions inherited from CDPBaseWidget
  • 4 public functions inherited from CDPBaseControlVisible

Public Slots

void saveAsPdf()
void saveAsPng()
void saveAsSvg()
void setDateTimeFormat(const QString &format)
void setDateTimeUtc(bool useUtc)
void setFileNamePostfix(const QString &postfix)
void setFileNamePrefix(const QString &prefix)
void setLockedTheme(const QString &theme)
void setSaveFolder(const QString &folder)
virtual void setWidgetTheme(const QString &theme) override
  • 10 public slots inherited from CDPBaseWidget

Signals

void pdfSaveFailed(const QString &reason)
void pdfSaved(const QString &filePath)
void pngSaveFailed(const QString &reason)
void pngSaved(const QString &filePath)
void svgSaveFailed(const QString &reason)
void svgSaved(const QString &filePath)
  • 1 signal inherited from CDPBaseWidget

Protected Functions

void showEvent(QShowEvent *event) override
  • 1 protected function inherited from CDPBaseControlVisible

Detailed Description

The Report Container is a container widget for composing exportable report pages from existing HMI widgets.

Drop any CDP Studio HMI widgets - labels, meters, node tables, pictures, etc. - into the Report Container and arrange them with normal layouts, exactly as you would inside a Container. When triggered, the Report Container renders its full contents to disk as a PNG, SVG or PDF file, using the file name and folder configured on the widget.

This is intended for operator workflows where the application needs to produce an audit log entry, end-of-shift report, daily summary, or similar artifact - either on demand from a button, or automatically when a control system signal fires.

Composing the report

Place the Report Container in your form, then drop the widgets that should appear in the report into it. Apply a layout (typically Vertical Layout) on the Report Container so the children arrange neatly.

Children are not limited to CDP Studio widgets - any visible widget will be rendered. Use labels, meters, node tables, pictures and grouping containers as you would on any normal page.

The Report Container paints a white background by default so the on-form preview and the exported file both look like a paper page. To use a different colour, change the palette property's Window role in the Designer property editor.

When the host application uses day/night theme switching, set lockedTheme to a fixed theme name to keep the report's appearance constant regardless of the surrounding HMI's theme - so the same form always produces visually identical exports.

Long reports and scrolling

When the report content is taller than the area available in the host window, place the Report Container inside a Scroll Area from the Designer Containers palette and set the scroll area's widgetResizable property to true. The scroll area will provide a vertical scroll bar at runtime while the Report Container itself keeps its natural full size.

Exports always capture the full report content, including parts that are currently scrolled out of view. There is no need to resize the window before triggering an export.

Triggering an export

The Report Container exposes one slot per output format:

  • saveAsPng() - write a PNG file.
  • saveAsSvg() - write a vector SVG file.
  • saveAsPdf() - write a single-page PDF file sized to the full content height.

The typical pattern is to add a single button next to (not inside) the Report Container in your form and connect its clicked() signal to whichever slot matches the format you have decided the report should be produced in, using Designer's connection mode. The operator does not need to choose the format - that decision is made when the form is designed. To trigger from the control system instead, connect a CDP boolean signal to the chosen slot through the standard CDPQt signal-slot bridge, exactly as you would for any other slot.

Each export emits a format-specific signal carrying the absolute path of the written file - pngSaved(path), svgSaved(path) or pdfSaved(path) - which can be wired directly to a label or to a CDP routing string output to display where the file was written. On failure, the matching pngSaveFailed, svgSaveFailed or pdfSaveFailed signal is emitted with a human-readable reason.

File naming

Files are written to the folder named in the saveFolder property - or, when saveFolder is left empty (the default), next to the running application's executable. The file name is built as:

<fileNamePrefix><timestamp><fileNamePostfix>.<extension>

where the timestamp is the current date and time formatted with dateTimeFormat (a standard date/time format string). With the default settings - prefix "report_", empty postfix, format "yyyyMMdd_HHmmss" - a save at 14:30:22 on 4 May 2026 produces report_20260504_143022.png (or .svg / .pdf).

Set the postfix to add a fixed suffix, e.g. an operator name or a unit identifier:

PropertyValue
fileNamePrefixTank3_
dateTimeFormatyyyy-MM-dd
fileNamePostfix_endOfShift

...produces Tank3_2026-05-04_endOfShift.png.

All filename parts are sanitised before being joined into a path - characters that are not legal in file names are replaced with underscores. The folder portion is used as-is, so the saveFolder property may contain forward slashes for nested directories. Folders are auto-created on first save if they do not already exist.

Working with reports under routing

Like any other CDP widget, the Report Container participates in the dialog routing system. If the form is opened by a Popup Dialog Button and replaceable routings are in use, all routed widgets inside the report will resolve their values against the substituted routing before the export is triggered. This makes it straightforward to design a single report dialog that produces reports for many components - configure a button per component with the appropriate routing replacement, and the same Report Container will produce a tailored output for each.

Property Documentation

dateTimeFormat : QString

This property holds the date/time format string used for the timestamp portion of the generated file name.

Default is "yyyyMMdd_HHmmss". The format uses the standard date/time placeholders - yyyy for year, MM for month, dd for day, HH for hour, mm for minute, ss for second. Set to an empty string to omit the timestamp entirely (useful when a fixed prefix and postfix are enough to identify the report and overwriting on each save is desired). The time zone used for the timestamp is controlled by dateTimeUtc.

Access functions:

QString dateTimeFormat() const
void setDateTimeFormat(const QString &format)

dateTimeUtc : bool

This property holds whether to use Coordinated Universal Time (UTC) for the timestamp in the generated file name.

When false (the default) the timestamp reflects the system's local time, which is the natural choice for reports an operator opens on the same machine. Set to true when the report files are aggregated into a multi-site audit log, archived to a fleet-management server, or otherwise consumed in a context where a single common time zone matters more than matching the wall clock at the application's location. The value is read every time a save is triggered, so the property can also be flipped at runtime through a CDP signal connection if needed.

Access functions:

bool dateTimeUtc() const
void setDateTimeUtc(bool useUtc)

fileNamePostfix : QString

This property holds the trailing part of the generated file name, between the timestamp and the file extension.

Default is empty. Useful for tagging exports with a fixed suffix such as an operator name, a unit identifier, or a shift label - for example "_endOfShift" produces report_20260504_143022_endOfShift.pdf.

Access functions:

QString fileNamePostfix() const
void setFileNamePostfix(const QString &postfix)

fileNamePrefix : QString

This property holds the leading part of the generated file name.

Default is "report_". Combined with the timestamp and postfix to form the file name, before the extension is appended. Set to an empty string to start the file name with the timestamp.

Access functions:

QString fileNamePrefix() const
void setFileNamePrefix(const QString &prefix)

lastSavedFilePath : const QString

This property holds read-only path to the most recently written export file.

Updated whenever saveAsPng, saveAsSvg or saveAsPdf completes successfully. Useful when the application needs to open or attach the file immediately after export, for example to display it in an external viewer.

Access functions:

QString lastSavedFilePath() const

lockedTheme : QString

This property holds the fixed theme name to use for the report container and its CDP child widgets, regardless of the application's current theme.

Defaults to "flat_light" so a freshly dropped Report Container looks paper-like and produces consistent exports without any extra configuration. Clear the value (set to an empty string) to make the Report Container behave like every other CDP widget - following the application-wide theme broadcasts and switching appearance whenever the user toggles day/night.

When set to a theme name, the container and every CDP descendant inside it stay on that theme even after the host application broadcasts a different one - useful for keeping report exports visually consistent across an archive that may have been generated at different times of day, and to give the on-screen preview a stable paper-like look. The recommended value for printable reports is "flat_gray_light". Other themes typically available in a default CDP Studio installation include "flat_gray", "cdp_light", "cdp_dark", "flat_light", "flat_dark" and the openbridge variants. The full set of available themes at runtime is the same list shown by the application's main window theme selector.

Only CDP Studio widgets honour the lock. Plain widgets dropped into the container draw with whatever colour and style configured on them in Designer and are not affected by theme switching in the first place.

Access functions:

QString lockedTheme() const
void setLockedTheme(const QString &theme)

saveFolder : QString

This property holds the folder where exported PNG/SVG/PDF files are written.

Defaults to empty, which causes exports to be written into the application's run directory. That directory always exists at runtime, so the default works without any configuration. Set this property to write reports somewhere else - e.g. an absolute path on a network share, or a path relative to the application's working directory. Forward slashes are accepted on all platforms. A non-empty folder is created automatically on first save if it does not exist; if creation fails, the format-specific save-failed signal is emitted instead of the saved signal.

Access functions:

QString saveFolder() const
void setSaveFolder(const QString &folder)

Member Function Documentation

ReportContainer::ReportContainer(QWidget *parent = 0)

Default constructs an instance of ReportContainer.

[virtual] ReportContainer::~ReportContainer()

Destroys the instance of ReportContainer. The destructor is virtual.

[signal] void ReportContainer::pdfSaveFailed(const QString &reason)

Emitted when saveAsPdf fails. reason is a human-readable description suitable for displaying to the operator.

[signal] void ReportContainer::pdfSaved(const QString &filePath)

Emitted after a successful saveAsPdf. filePath is the absolute path of the written PDF file.

[signal] void ReportContainer::pngSaveFailed(const QString &reason)

Emitted when saveAsPng fails. reason is a human-readable description suitable for displaying to the operator.

[signal] void ReportContainer::pngSaved(const QString &filePath)

Emitted after a successful saveAsPng. filePath is the absolute path of the written PNG file.

[slot] void ReportContainer::saveAsPdf()

Renders the full Report Container contents to a PDF file in saveFolder. The PDF is produced as a single page sized to fit the entire report height. Emits pdfSaved on success or pdfSaveFailed on failure.

[slot] void ReportContainer::saveAsPng()

Renders the full Report Container contents to a PNG file in saveFolder. Emits pngSaved on success or pngSaveFailed on failure. PNG output preserves transparency and is appropriate for embedding in other documents or attaching to email.

[slot] void ReportContainer::saveAsSvg()

Renders the full Report Container contents to a vector SVG file in saveFolder. Emits svgSaved on success or svgSaveFailed on failure. SVG output stays crisp at any zoom level and keeps text selectable when opened in a browser.

[override virtual slot] void ReportContainer::setWidgetTheme(const QString &theme)

[protected] void ReportContainer::showEvent(QShowEvent *event)

[signal] void ReportContainer::svgSaveFailed(const QString &reason)

Emitted when saveAsSvg fails. reason is a human-readable description suitable for displaying to the operator.

[signal] void ReportContainer::svgSaved(const QString &filePath)

Emitted after a successful saveAsSvg. filePath is the absolute path of the written SVG file.

The content of this document is confidential information not to be published without the consent of CDP Technologies AS.

CDP Technologies AS, www.cdpstudio.com

Get started with CDP Studio today

Let us help you take your great ideas and turn them into the products your customer will love.

Try CDP Studio for free
Why CDP Studio?

CDP Technologies AS
Hundsværgata 8,
P.O. Box 144
6001 Ålesund, Norway

Tel: +47 990 80 900
E-mail: info@cdptech.com

Company

About CDP

Contact us

Services

Partners

Blog

Developers

Get started

User manuals

Support

Document download

Release notes

My account

Follow CDP

  • LinkedIn
  • YouTube
  • GitHub

© Copyright 2026 CDP Technologies. Privacy and cookie policy.

Return to top