QT时钟的创建
来源:互联网 发布:centos无线网络配置 编辑:程序博客网 时间:2024/05/20 19:46
1.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: //关键字
void showTime();
private:
Ui::Logo *ui;
QTimer *timer;
};
#endif // MAINWINDOW_H
#include "Logo.h"
#include "ui_mainwindow.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);//设置显示数字位数
QTimer *timer=new QTimer(this);
connect(timer,SIGNAL(timeout()),this, SLOT(showTime()));
timer->start(1000);
showTime();
setWindowTitle(tr("Digital Clock"));
LCD->resize(150,60);
}
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.图片方式显示
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->month2->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 a");
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"));
}
- QT时钟的创建
- Qt--时钟插件的创建与使用
- 使用Qt创建模拟时钟
- Qt的时钟Example
- Qt - 与众不同的电子时钟
- qt编译时, make:警告:检测时钟错误。您的创建可能是不完整的。
- QT时钟
- Qt -- 时钟
- 基于QT的时钟模拟程序
- 一个最简单的QT数字时钟
- 创建时钟
- C#时钟控件的创建与使用
- C#时钟控件的创建与使用
- 使用Canvas创建的时钟小程序
- 类的创建与基本应用--时钟
- 【Qt编程】Qt 小时钟
- QT GUI 简易时钟
- qt 修改系统时钟
- Struts2常用标签总结
- 内核启动用户态的程序
- IOS开发 沙盒中的文件操作
- 二分查找容易忽略的一个bug
- GDB 格式化结构体输出
- QT时钟的创建
- 内核中的notification chain浅析
- 老码农教你学英语:补充一些英语学习素材
- Winsock网络编程快速入门
- 仿google suggest
- 关于向量积和叉积的解释
- 内核中接收网络帧的处理(2层)
- uva 10125 Sumsets(搜索)
- Activity实现欢迎界面并添加动画切换效果