周报——QT可设置系统时间
2014-10-17 20:50
856 查看
昵称:cmj 日期:2014年10月10日—2014年10月17日
1、本周已完成任务:可设置系统时间
2、本周未完成任务:qt界面在显示屏的显示
3、下周计划:(1)、继续解决qt在cvbs上的显示问题 (2)、所要实现的功能需要各个模块配合
4、关键键技术点说明:
4.1hi_rtc驱动源码:
1、本周已完成任务:可设置系统时间
2、本周未完成任务:qt界面在显示屏的显示
3、下周计划:(1)、继续解决qt在cvbs上的显示问题 (2)、所要实现的功能需要各个模块配合
4、关键键技术点说明:
4.1hi_rtc驱动源码:
static long hi_rtc_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { unsigned long flags; int ret; rtc_time_t time; reg_data_t reg_info; reg_temp_mode_t temp_mode; switch (cmd) { ... ... case HI_RTC_RD_TIME: //读取rtc时间
<span style="white-space:pre"> </span>HI_MSG("HI_RTC_RD_TIME"); hirtc_get_time(&time); ret = copy_to_user((void *)arg, &time, sizeof(time)); if (ret) { return -EFAULT; } break; case HI_RTC_SET_TIME: HI_MSG("HI_RTC_SET_TIME"); ret = copy_from_user(&time, (struct rtc_time_t *) arg, sizeof(time)); if (ret) { return -EFAULT; } hirtc_set_time(time); break; ... default: return -EINVAL; } return 0; }
typedef struct { unsigned int year; unsigned int month; unsigned int date; unsigned int hour; unsigned int minute; unsigned int second; unsigned int weekday; } rtc_time_t;
#define HI_RTC_RD_TIME _IOR('p', 0x09, rtc_time_t) #define HI_RTC_SET_TIME _IOW('p', 0x0a, rtc_time_t)
qt程序
<P>#include "mainwindow.h" #include "ui_mainwindow.h" #include "hi_rtc.h" #include <fcntl.h> #include <sys/ioctl.h> #include <QFile> #include <QDebug> #include <QDateTime> static int fb;//静态设备号 MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); } MainWindow::~MainWindow() { delete ui; } void MainWindow::changeEvent(QEvent *e) { QMainWindow::changeEvent(e); switch (e->type()) { case QEvent::LanguageChange: ui->retranslateUi(this); break; default: break; } } void MainWindow::settime() //设置rtc时间 { rtc_time_t tm; tm.year = 2014; tm.month = 10; tm.date = 17; tm.hour = 13; tm.minute = 13; tm.second = 00; tm.weekday =0; QFile f("/dev/hi_rtc");//定义led驱动文件 if (f.exists())//如果文件存在 { fb = open("/dev/hi_rtc", QIODevice::ReadWrite);//读写方式打开文件 if (fb < 0)//打开驱动文件错误 { perror("open device leds fail");//输入错误信息 // return ;//返回 } } ioctl(fb, HI_RTC_SET_TIME, &tm); ::close(fb); }
void MainWindow::gettime()//读取RTC时间 { rtc_time_t tm; QFile f("/dev/hi_rtc");//定义led驱动文件 qDebug()<<1; if (f.exists())//如果文件存在 { fb = open("/dev/hi_rtc", QIODevice::ReadWrite);//读写方式打开文件 qDebug()<<2; if (fb < 0)//打开驱动文件错误 { qDebug()<<3; perror("open device leds fail");//输入错误信息 // return ;//返回 } } ioctl(fb, HI_RTC_RD_TIME, &tm);//读取rtc时间 qDebug()<<tm.year<<tm.month<<tm.date<<tm.hour<<tm.minute<<tm.second; ::close(fb); } void MainWindow::setsystime() //设置系统时间 { QString time; time = "date 010101012000"; system(time.toLatin1().data()); //.toLatin1().data()作用是将QString转char* ; // system("date 010101012000"); } void MainWindow::getsystime() //获得系统时间 { QDateTime time = QDateTime::currentDateTime();//获取系统现在的时间 QString str = time.toString("yyyy-MM-dd hh:mm:ss ddd"); //设置显示格式 qDebug()<<str; }
相关文章推荐
- QT 设置系统时间
- Qt中设置系统时间,调用system()函数
- QT在linux环境下读取和设置系统时间
- QT获取系统时间,以及设置日期格式
- 【转】QT获取系统时间,以及设置日期格式
- Qt设置系统时间
- Qt linux下设置系统时间
- Qt4 设置系统日期时间
- qt4 设置系统日期 时间,set time date, set system date time
- qt4 设置系统日期 时间,set time date, set system date time
- QT——设置窗口的固定大小、QProcess、定时器事件、QString::arg、系统时间、QPixmap 和 QImage 区别
- QT修改、获取系统时间,以及设置日…
- Qt设置系统时间(使用SetSystemTime API函数)
- QT在linux环境下读取和设置系统时间(通过system来直接调用Linux命令,注意权限问题)
- Qt中设置win7的系统时间
- QT获取系统时间,以及设置日期格式
- Qt设置系统时间
- QT获取系统时间以及设置日期格式
- QT下设置Linux系统时间
- QT获取系统时间,以及设置日期格式