Skip to content

Time Format Editor

DATimeFormatEditWidget provides a time format setting control that allows the user to select or type a time display format string.

Preview

DATimeFormatEditWidget: preset format dropdown and live preview

The dropdown offers common date/time presets, and the format string remains editable. The demo renders the current time with the chosen format below so the result can be checked immediately.

Key Features

  • ✅ Format presets: Provides common time format presets
  • ✅ Custom input: Supports manually typing a format string
  • ✅ Signal notification: Emits a signal when the format changes

Usage

1
2
3
4
5
6
7
8
9
#include "DATimeFormatEditWidget.h"

auto *timeEdit = new DA::DATimeFormatEditWidget(parent);

// Set the time format
timeEdit->setTimeFormatText("yyyy-MM-dd HH:mm:ss");

// Get the current format
QString format = timeEdit->getTimeFormat();

Format Syntax

The format string uses Qt's date/time format tokens: yyyy (4-digit year), MM (2-digit month), dd (2-digit day), HH (24-hour), mm (minutes), ss (seconds). See the Qt documentation for the full list.

Core Properties & Methods

Method Description
getTimeFormat() Get the current time format string
setTimeFormatText(QString) Set the time format string

References