資源簡(jiǎn)介
qt改進(jìn)的電子時(shí)鐘,并加上類似photoshop啟動(dòng)時(shí)的歡迎界面
感興趣的可以參考
代碼片段和文件信息
#include?“digiclock.h“
#include?
DigiClock::DigiClock(QWidget?*parent)
:?QLCDNumber(parent)
{
????QTest::qWait(2000);
????QPalette?p?=?palette();
????p.setColor(QPalette::WindowQt::darkGreen);
????setPalette(p);
????setWindowFlags(Qt::framelessWindowHint);
????setframestyle(Qframe::Panel?|?Qframe::Raised);
????this->setNumDigits(19);
????setGeometry(QApplication::desktop()->width()?/?2?-?200?QApplication::desktop()->height()?/?2?-?25?400?50);
????QTimer?*timer?=?new?QTimer(this);
????connect(timer?SIGNAL(timeout())?this?SLOT(showTime()));
????timer->start(500);
????showTime();
showColon=true;
}
void?DigiClock::showTime()
{
?????QDateTime?time?=?QDateTime::currentDateTime();
?????QString?text?=?time.toString(“yyyy-MM-dd?hh:MM:ss“);
?????if(showColon)?{
????????text[16]?=?‘:‘;
????? showColon?=?false;
?????}
?????else?{
????????text[16]?=?‘?‘;
????? showColon?=?true;?????
?????}
?????display(text);
}
?
void?DigiClock::mousePressEvent(QMouseEvent?*?e)
{
????if?(e->button()?==?Qt::LeftButton)?{
???? dragPosition?=?e->globalPos()?-?frameGeometry().topLeft();
???? e->accept();
????}
????if?(e->button()?==?Qt::RightButton)?{
???? close();
????}????
}
void?DigiClock::mouseMoveEvent(QMouseEvent?*?e)
{
????if?(e->buttons()?&?Qt::LeftButton)?{
???? move(e->globalPos()?-?dragPosition);
???? e->accept();
????}
}
評(píng)論
共有 條評(píng)論