Ktam3874/pitx software guide – Kontron KTAM3874-pITX User Manual
Page 209

KTD-S0057-I
Page 205 Linux® Programming Examples (DebianTM)
KTAM3874/pITX Software Guide
#include
#include "ui_dialog.h"
#include "moc_main.cpp"
Dialog::Dialog (QWidget *parent) : QDialog (parent), ui (new Ui::Dialog)
{
ui->setupUi
(this);
// only an example for subsequent modifications of calendar features
ui->
calendarWidget
->setMinimumDate (QDate (2014, 1, 1));
ui->
calendarWidget
->setMaximumDate (QDate (2020, 1, 1));
ui->
calendarWidget
->setSelectedDate (QDate (2014, 2, 28));
ui->
calendarWidget
->setGridVisible (true);
ui->
calendarWidget
->setHorizontalHeaderFormat (QCalendarWidget::SingleLetterDayNames);
// change color and other properties of the label widget (date display)
QPalette p_lab = ui->
label
->palette ();
p_lab.setColor
(QPalette::WindowText,
Qt::blue);
ui->
label
->setAutoFillBackground (true);
ui->
label
->setPalette (p_lab);
ui->
label
->setFrameStyle (QFrame::Panel | QFrame::Sunken);
ui->
label
->setAlignment (Qt::AlignCenter);
// update the label widget and link Font Combo Box and Calendar to the drawDate routine
QObject::connect
(ui->
fontComboBox
, SIGNAL (currentFontChanged (const QFont &)), this,
SLOT
(drawDate
()));
QDate date = ui->
calendarWidget
->selectedDate ();
ui->
label
->setText (date.toString ());
QObject::connect
(ui->
calendarWidget
, SIGNAL (selectionChanged ()), this, SLOT (drawDate ()));
// change the color of LCD Number widget
QPalette p_lcd = ui->
lcdNumber
->palette ();
p_lcd.setColor
(QPalette::WindowText,
Qt::red);
ui->
lcdNumber
->setPalette (p_lcd);
// link a timer to the showTime routine and start the timer
QTimer *timer = new QTimer (this);
QObject::connect (timer, SIGNAL (timeout ()), this, SLOT (showTime ()));
timer->start
(TIMEOUT);
}
Dialog::~Dialog ()
{
delete
ui;
}
void Dialog::drawDate ()
{
QFont font = ui->
fontComboBox
->currentFont ();
font.setPointSize
(FONTSIZE);
ui->
label
->setFont (font);
QDate date = ui->
calendarWidget
->selectedDate ();
ui->
label
->setText (date.toString ());
}