• 大小: 734KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-13
  • 语言: C/C++
  • 标签: QT  clock  c++  

资源简介

QT 4.7版本写的电子时钟,里面有windows版本和linux版本

资源截图

代码片段和文件信息

#include “digiclock.h“
#include 
DigiClock::DigiClock(QWidget *parent) :
    QLCDNumber(parent)
{
    //设置时钟的背景
    QPalette p = palette();
    p.setColor(QPalette::WindowQt::green);                            //设置主题颜色,具体颜色为绿色
    setPalette(p);
    setWindowFlags(Qt::framelessWindowHint);                     //设置一个无窗口边框的窗体(此时用户无法移动窗体)
    setWindowOpacity(0.5);                                                        //设置窗体半透明
    QTimer *timer = new QTimer(this);
    connect(timerSIGNAL(timeout())thisSLOT(showTime()));
    timer->start(1000);
    showTime();
    resize(15060);
    showColon = true;                                                                //用作判断是否显示时间
}

void DigiClock::showTime()
{
    QTime time = QTime::currentTime();
    QString text = time.toString(“hh:mm“);
    if(showColon)           //每秒一闪一闪:[上面有计时器timer->start(1000)]
    {
     text[2] = ‘:‘ ;
     showColon = false;
    }
    else
    {
        text[2] = ‘ ‘;
        showColon = true;
    }
    display(text);              //显示时钟
}

void DigiClock::mousePressEvent(QMouseEvent *event)
{
    if(event->button() == Qt::LeftButton)//点击了左键
    {
        dragPosition = event->globalPos()-frameGeometry().topLeft();//globalPos返回鼠标全局的位子,frameGeometry返回不含边框的信息,topleft返回矩形的左上角
        event->accept();
    }
    if(event->button() == Qt::RightButton)
   {
    close();
    }

}

void DigiClock::mouseMoveEvent(QMouseEvent *event)
{
 if(event->buttons()&Qt::LeftButton )
 {
     move(event->globalPos()-dragPosition);//将时钟移动到[鼠标全局的位置 - 鼠标相对电子时钟窗体左上角的偏移值]
     event->accept();
 }
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       1784  2016-11-06 13:20  clock\digital clock1\clock\clock.cpp

     文件        325  2016-11-06 13:22  clock\digital clock1\clock\clock.pro

     文件      19030  2016-11-06 13:26  clock\digital clock1\clock\clock.pro.user

     文件        656  2016-11-06 13:24  clock\digital clock1\clock\digiclock.h

     文件        189  2016-11-06 13:20  clock\digital clock1\clock\main.cpp

     文件        654  2016-11-06 11:03  clock\digital clock1\clock\mainwindow.ui

     文件     979631  2016-11-06 13:24  clock\digital clock1\clock-build-desktop-Qt_4_8_0_for_Desktop_-_MinGW__Qt_SDK____\debug\clock.exe

     文件     283320  2016-11-06 13:24  clock\digital clock1\clock-build-desktop-Qt_4_8_0_for_Desktop_-_MinGW__Qt_SDK____\debug\clock.o

     文件     184282  2016-11-06 13:24  clock\digital clock1\clock-build-desktop-Qt_4_8_0_for_Desktop_-_MinGW__Qt_SDK____\debug\main.o

     文件       2876  2016-11-06 13:24  clock\digital clock1\clock-build-desktop-Qt_4_8_0_for_Desktop_-_MinGW__Qt_SDK____\debug\moc_digiclock.cpp

     文件     197362  2016-11-06 13:24  clock\digital clock1\clock-build-desktop-Qt_4_8_0_for_Desktop_-_MinGW__Qt_SDK____\debug\moc_digiclock.o

     文件       7153  2016-11-06 13:23  clock\digital clock1\clock-build-desktop-Qt_4_8_0_for_Desktop_-_MinGW__Qt_SDK____\Makefile

     文件       6475  2016-11-06 13:23  clock\digital clock1\clock-build-desktop-Qt_4_8_0_for_Desktop_-_MinGW__Qt_SDK____\Makefile.Debug

     文件       6548  2016-11-06 13:23  clock\digital clock1\clock-build-desktop-Qt_4_8_0_for_Desktop_-_MinGW__Qt_SDK____\Makefile.Release

     文件       2232  2016-11-06 11:06  clock\digital clock1\clock-build-desktop-Qt_4_8_0_for_Desktop_-_MinGW__Qt_SDK____\ui_mainwindow.h

     文件        330  2016-11-06 13:46  clock\digital clock2\clock\clock.pro

     文件      19030  2016-11-06 14:28  clock\digital clock2\clock\clock.pro.user

     文件        596  2016-11-06 14:25  clock\digital clock2\clock\dialogclock.cpp

     文件        361  2016-11-06 14:13  clock\digital clock2\clock\dialogclock.h

     文件        916  2016-11-06 14:23  clock\digital clock2\clock\dialogclock.ui

     文件        195  2016-11-06 13:46  clock\digital clock2\clock\main.cpp

     文件     817196  2016-11-06 14:27  clock\digital clock2\clock-build-desktop-Qt_4_8_0_for_Desktop_-_MinGW__Qt_SDK____\debug\clock.exe

     文件     221988  2016-11-06 14:27  clock\digital clock2\clock-build-desktop-Qt_4_8_0_for_Desktop_-_MinGW__Qt_SDK____\debug\dialogclock.o

     文件     121551  2016-11-06 14:13  clock\digital clock2\clock-build-desktop-Qt_4_8_0_for_Desktop_-_MinGW__Qt_SDK____\debug\main.o

     文件       2905  2016-11-06 14:16  clock\digital clock2\clock-build-desktop-Qt_4_8_0_for_Desktop_-_MinGW__Qt_SDK____\debug\moc_dialogclock.cpp

     文件     133691  2016-11-06 14:16  clock\digital clock2\clock-build-desktop-Qt_4_8_0_for_Desktop_-_MinGW__Qt_SDK____\debug\moc_dialogclock.o

     文件       7153  2016-11-06 14:11  clock\digital clock2\clock-build-desktop-Qt_4_8_0_for_Desktop_-_MinGW__Qt_SDK____\Makefile

     文件       6576  2016-11-06 14:11  clock\digital clock2\clock-build-desktop-Qt_4_8_0_for_Desktop_-_MinGW__Qt_SDK____\Makefile.Debug

     文件       6649  2016-11-06 14:11  clock\digital clock2\clock-build-desktop-Qt_4_8_0_for_Desktop_-_MinGW__Qt_SDK____\Makefile.Release

     文件       1741  2016-11-06 14:24  clock\digital clock2\clock-build-desktop-Qt_4_8_0_for_Desktop_-_MinGW__Qt_SDK____\ui_dialogclock.h

............此处省略14个文件信息

评论

共有 条评论