1. Use of qlcdnumber
# Ifndef mainwindow_h
# Define mainwindow_h
# Include <qmainwindow>
# Include <qtime>
# Include <qtimer>
# Include <qmessagebox>
# Include <qtgui/qlcdnumber>
Namespace UI {
Class logo;
}
Class logo: Public qmainwindow
{
Q_object
Public:
Explicit logo (qwidget * parent = 0 );
~ Logo ();
Qlcdnumber * LCD;
Private slots: // keyword
Void Showtime ();
PRIVATE:
Ui: logo * UI;
Qtimer * timer;
};
# Endif // mainwindow_h
# Include "logo. H"
# Include "ui_main1_1_h"
Logo: logo (qwidget * parent ):
Qmainwindow (parent ),
UI (new UI: logo)
{
UI-> setupui (this );
Qt: windowflags new_flags = 0;
New_flags = QT: Window | QT: framelesswindowhint;
Setwindowflags (new_flags );
Setgeometry (0, 0, 480,272 );
Qpixmap background;
Background = qpixmap ("D:/qtsdk/qtcreator/newproject/jiemian.jpg ");
Qpalette palette;
Palette. setbrush (qwidget: backgroundrole (), qbrush (background ));
Setpalette (palette );
Timer = new qtimer (this );
// Timer-> Start (2000 );
Connect (timer, signal (timeout (), this, slot (mylogo ));
LCD = new qlcdnumber (this );
LCD-> setsegmentstyle (qlcdnumber: filled );
LCD-> setnumdigits (8); // you can specify the number of digits to display.
Qtimer * timer = new qtimer (this );
Connect (timer, signal (timeout (), this, slot (Showtime ()));
Timer-> Start (1000 );
Showtime ();
Setwindowtitle (TR ("Digital Clock "));
LCD-> resize );
}
Logo ::~ Logo ()
{
Delete UI;
}
Void logo: Showtime ()
{
Qtime time = qtime: currenttime ();
Qstring text = time. tostring ("HH: mm: SS ");
If (time. Second () % 2) = 0)
{
Text [2] = '';
Text [5] = '';
}
LCD-> display (text );
}
2. Image Display
Void login: showdate ()
{
Qdate date = qdate: currentdate ();
Qstring text_date = date. tostring ("yyyy/mm/dd ddd ");
// Label_date-> settext (text_date );
UI-> yearh1-> setpixmap (qpixmap (geticonname (text_date [0]);
UI-> year2-> setpixmap (qpixmap (geticonname (text_date [1]);
UI-> year3-> setpixmap (qpixmap (geticonname (text_date [2]);
UI-> year4-> setpixmap (qpixmap (geticonname (text_date [3]);
// UI-> Xie-> setpixmap (qpixmap (geticonname (text_date [4]);
UI-> month1-> setpixmap (qpixmap (geticonname (text_date [5]);
UI-> mon22-> setpixmap (qpixmap (geticonname (text_date [6]);
// UI-> xie1-> setpixmap (qpixmap (geticonname (text_date [7]);
UI-> day1-> setpixmap (qpixmap (geticonname (text_date [8]);
UI-> day2-> setpixmap (qpixmap (geticonname (text_date [9]);
}
Void login: Showtime ()
{
Qtime time = qtime: currenttime ();
Qstring text = time. tostring ("HH: mm: ss ");
UI-> hourh-> setpixmap (qpixmap (geticonname (Text [0]);
UI-> hourl-> setpixmap (qpixmap (geticonname (Text [1]);
// UI-> mouhao-> setpixmap (qpixmap (geticonname (Text [2]);
UI-> Minh-> setpixmap (qpixmap (geticonname (Text [3]);
UI-> minl-> setpixmap (qpixmap (geticonname (Text [4]);
// UI-> maohao1-> setpixmap (qpixmap (geticonname (Text [5]);
UI-> Sech-> setpixmap (qpixmap (geticonname (Text [6]);
UI-> secl-> setpixmap (qpixmap (geticonname (Text [7]);
// Label_time-> settext (text_time );
}
Qstring login: geticonname (qchar X)
{
Return (qstring (":/file/images/") + x + qstring (". GIF "));
}