資源簡(jiǎn)介
基于linux QT開(kāi)發(fā)的萬(wàn)年歷程序
結(jié)構(gòu)比較清晰 兩層 界面層+邏輯層
在fedora 9下 用qt4.5.0開(kāi)發(fā)

代碼片段和文件信息
/*
?*File:calendar.cpp?
?*Auther:WTT?@?USST
?*mday:2010-08-20
?*Note:copy?right?by?WTT
?*Mail:jbx-gentleman@hotmail.com
?*
?*?
?*
?*/
#include
#include
#include?“time.h“
#include?“calendar.h“
#include?
#include?
#include?
#include?
calendar::calendar(QWidget?*parent?)?:?QWidget(parent)
{
ui.setupUi(this);
today();
connect(ui.bt_today?SIGNAL(clicked())?this?SLOT(today()));
//this->setWindowFlags(Qt::framelessWindowHint);///去掉標(biāo)題欄
}
void?calendar::today()
{
ui.lb_sun->setText(QApplication::translate(“Form“?“SUN.“?0?QApplication::UnicodeUTF8));
QDateTime?dt=QDateTime::currentDateTime();
QDate?cur_date=dt.date();
my_tm.cur_time=(struct?tm?*)malloc(sizeof(struct?tm?*));
my_tm.today=(struct?tm?*)malloc(sizeof(struct?tm?*));
my_tm.cur_time->yearH=cur_date.year()/100;
my_tm.cur_time->yearL=cur_date.year()%100;
my_tm.cur_time->month=cur_date.month();
my_tm.cur_time->mday=cur_date.day();
my_tm.today->yearH=cur_date.year()/100;
my_tm.today->yearL=cur_date.year()%100;
my_tm.today->month=cur_date.month();
my_tm.today->mday=cur_date.day();
QString?str;
QByteArray?ba;
const?char?*c_str;?
str=QString::number(my_tm.get_int_year(my_tm.cur_time));
ba?=?str.toLatin1();
? c_str?=?ba.data();?
//ui.grid[0][0]->setText(QApplication::translate(“Form“c_str?0?QApplication::UnicodeUTF8)); //test?code
ui.le_year->setText(QApplication::translate(“Form“?c_str?0?QApplication::UnicodeUTF8));
ui.sb_year->setValue(my_tm.get_int_year(my_tm.cur_time));
str=QString::number(my_tm.cur_time->month);
ba?=?str.toLatin1();
? c_str?=?ba.data();?
ui.le_month->setText(QApplication::translate(“Form“?c_str?0?QApplication::UnicodeUTF8));
ui.sb_month->setValue(my_tm.cur_time->month);
str=QString::number(my_tm.cur_time->mday);
ba?=?str.toLatin1();
? c_str?=?ba.data();?
ui.le_date->setText(QApplication::translate(“Form“?c_str?0?QApplication::UnicodeUTF8));
show_calendar();
connect(ui.sb_year?SIGNAL(valueChanged(int))?this?SLOT(change_year()));
connect(ui.sb_month?SIGNAL(valueChanged(int))?this?SLOT(change_month()));
}
void?calendar::show_calendar()
{
int?tempday=my_tm.cur_time->mday;
int?tempmonth=my_tm.cur_time->month;
int?tempyearH=my_tm.cur_time->yearH;
int?tempyearL=my_tm.cur_time->yearL;
int?ijmod;
QString?str;
QByteArray?ba;
const?char?*c_str;?
my_tm.cur_time->mday=1;
mod=my_tm.day_of_week(my_tm.cur_time)%7;
for(;mod>0;mod--)
{
my_tm.sub_day(my_tm.cur_time);
}
for(i=0;i<6;i++)
for(j=0;j<7;j++)
{
str=QString::number(my_tm.cur_time->mday);
ba?=?str.toLatin1();
? c_str?=?ba.data();?
ui.grid[i][j]->setText(QApplication::translate(“Form“c_str?0?QApplication::UnicodeUTF8));
if( ((my_tm.cur_time->yearH)==(my_tm.today->yearH)) //today
&&((my_tm.cur_time->yearL)==(my_tm.today->yearL))
&&((my_tm.cur_time->month)==(my_tm.today->month))
&&((my_tm.cur_time->mday)==(my_tm.today->mday)) )
{
ui
?屬性????????????大小?????日期????時(shí)間???名稱(chēng)
-----------?---------??----------?-----??----
?????文件??????63126??2010-08-22?20:31??calendar\calendar
?????文件???????6065??2010-08-22?20:31??calendar\calendar.cpp
?????文件????????722??2010-08-22?20:31??calendar\calendar.h
?????文件??????46264??2010-08-22?20:31??calendar\calendar.o
?????文件????????368??2010-08-22?20:31??calendar\calendar.pro
?????文件??????20194??2010-08-22?20:31??calendar\calendar.ui
?????文件??????21626??2010-08-22?20:31??calendar\calendar_UI_back.h
?????文件????????753??2010-08-22?20:31??calendar\main.cpp
?????文件???????3192??2010-08-22?20:31??calendar\main.o
?????文件???????8335??2010-08-22?20:31??calendar\Makefile
?????文件???????2296??2010-08-22?20:31??calendar\moc_calendar.cpp
?????文件???????8268??2010-08-22?20:31??calendar\moc_calendar.o
?????文件??????26349??2010-08-22?20:31??calendar\time.cpp
?????文件???????3056??2010-08-22?20:31??calendar\time.h
?????文件???????7060??2010-08-22?20:31??calendar\time.o
?????文件??????21625??2010-08-22?20:31??calendar\ui_calendar.h
?????文件??????????0??2010-08-22?20:31??calendar\不要make?clean?如果要改ui界面?grid數(shù)組等需要手動(dòng)修改
?????文件????????383??2010-08-22?20:38??calendar\本程序待改進(jìn)處
?????目錄??????????0??2010-08-22?20:32??calendar
-----------?---------??----------?-----??----
???????????????239682????????????????????19
評(píng)論
共有 條評(píng)論