没有合适的资源?快使用搜索试试~ 我知道了~
Qt_Creater开发万年历(C++)
需积分: 10 22 下载量 123 浏览量
2014-12-02
21:02:13
上传
评论 3
收藏 159KB DOC 举报
温馨提示
试读
24页
关于QT的一点学习资料,可供大家参考,仅做初学者学习之用
资源推荐
资源详情
资源评论
1.Calendar.cpp
#include <QtGui>
#include "calendar.h"
#include <QIcon>
#include <QDebug>
#include <QPainter>
#include <QDateTime>
#include "itembutton.h"
#include "lunarday.h"
using namespace lunar;
Calendar::Calendar(QWidget *parent)
:QWidget(parent)
{
//当前年份
QDateTime dt;
QTime time;
QDate date;
dt.setTime(time.currentTime());
dt.setDate(date.currentDate());
QString currentDate = dt.toString("yyyy:MM:dd:hh:mm:ss");
QStringList currentDateList = currentDate.split(":");
newyear=currentDateList.at(0).toInt();
newmonth=currentDateList.at(1).toInt();
newday=currentDateList.at(2).toInt();
m_bgBlackPixmap = QPixmap::fromImage(QImage(tr("./images/cumputerback.png")));//
m_barPixmap= QPixmap::fromImage(QImage(tr("./images/bar.png")));//
m_bgPixmap = QPixmap::fromImage(QImage(tr("./images/calendarback.png")));//
//退出按钮
m_btnQuit = new QLabel(this);
QPixmap quitPixmap = QPixmap::fromImage(QImage("./images/quit.png"));
//setPixmap 设置图片,
m_btnQuit->setPixmap(quitPixmap);
//设置大小
m_btnQuit->resize(78, 65);
//移动
m_btnQuit->move(800 - 78, 0);
// Box = new QLabel(this);
// QPixmap BoxPixmap1 = QPixmap::fromImage(QImage("./images/stand_light"));
// Box->setPixmap(BoxPixmap1);
// Box->resize(58,48);
// //qDebug()<<m_i<<m_j;
// Box->move(210+83*m_i,180+40*m_j);
// Box->show();
//向下年份按钮
yearreduce = new QLabel(this);
QPixmap leftPixmap1 = QPixmap::fromImage(QImage("./images/left.png"));
yearreduce->setPixmap(leftPixmap1);
yearreduce->resize(54,54);
yearreduce->move(230,80);
//向下月份按钮
monthreduce = new QLabel(this);
QPixmap leftPixmap2 = QPixmap::fromImage(QImage("./images/left.png"));
monthreduce->setPixmap(leftPixmap2);
monthreduce->resize(54,54);
monthreduce->move(530,80);
//向上年份按钮
yearadd = new QLabel(this);
QPixmap rightPixmap1 = QPixmap::fromImage(QImage("./images/right.png"));
yearadd->setPixmap(rightPixmap1);
yearadd->resize(54,54);
yearadd->move(435,80);
//向上月份按钮
monthadd = new QLabel(this);
QPixmap rightPixmap2 = QPixmap::fromImage(QImage("./images/right.png"));
monthadd->setPixmap(rightPixmap2);
monthadd->resize(54,54);
monthadd->move(730,80);
//设置公历
m_gregorian = new itemButton(this);
m_gregorian->setTextColor(Qt::white);
m_gregorian->resize(176, 49);
m_gregorian->setRect(QRect(0,0 , 176, 49));
m_gregorian->setAlignment(Qt::AlignLeft);
m_gregorian->setTextFont(QFont("宋体", 18));
m_gregorian->setText(tr("公历"));
m_gregorian->move(20, 95);
QString
currentgregorian=currentDateList.at(0)+"-"+currentDateList.at(1)+"-"+currentDateList.at(2);
gregoriandisplay=new itemButton(this);
gregoriandisplay->setTextColor(Qt::white);
gregoriandisplay->resize(176, 49);
gregoriandisplay->setRect(QRect(20,0 , 176, 49));
gregoriandisplay->setAlignment(Qt::AlignLeft);
gregoriandisplay->setTextFont(QFont("宋体", 18));
gregoriandisplay->setText(currentgregorian);
gregoriandisplay->move(55,95);
//设置万年历
m_btncalendar=new itemButton(this);
m_btncalendar->setTextColor(Qt::white);
m_btncalendar->resize(176, 49);
m_btncalendar->setRect(QRect(0,0 , 176, 49));
m_btncalendar->setAlignment(Qt::AlignLeft);
m_btncalendar->setTextFont(QFont("宋体", 20));
m_btncalendar->setText(tr("万年历"));
m_btncalendar->move(45,20);
//设置农历
m_lunar = new itemButton(this);
m_lunar->setTextColor(Qt::white);
m_lunar->resize(176, 49);
m_lunar->setRect(QRect(0,0 , 176, 49));
m_lunar->setAlignment(Qt::AlignLeft);
m_lunar->setTextFont(QFont("宋体", 20));
m_lunar->setText(tr("农历"));
m_lunar->move(20, 145);
QString b[30]={" 初一","初二","初三","初四","初五","初六","初七","初八","初九","初
十","十一","十二","十三","十四",
"十五","十六","十七","十八","十九","二十","廿一","廿二","廿三","廿四","廿五","廿
六","廿七","廿八","廿九","三十"};
QString c[12]={"正月","二月","三月","四月","五月","六月","七月","八月","九月","十
月","十一月","腊月",};
bool ok;
rili();
int tempmonth=currentDateList.at(1).toInt(&ok,10)-1;
if(currentDateList.at(1).toInt(&ok,10)==1)
{
tempmonth=12;
}
lunardisplay=new itemButton(this);
lunardisplay->setTextColor(Qt::white);
lunardisplay->resize(176, 49);
lunardisplay->setRect(QRect(40,0 ,176, 49));
lunardisplay->setAlignment(Qt::AlignLeft);
lunardisplay->setTextFont(QFont("宋体", 18));
lunardisplay->setText(c[tempmonth-1]);
lunardisplay->move(55,145);
//返回今日
m_getback = new itemButton(this);
m_getback->setTextColor(Qt::white);
m_getback->resize(176, 49);
m_getback->setRect(QRect(0,0 , 176, 49));
m_getback->setAlignment(Qt::AlignCenter);
m_getback->setTextFont(QFont("宋体", 18));
m_getback->setText(tr("返回今日"));
m_getback->move(5, 185);
//当前年份
year=new itemButton(this);
year->setTextColor(Qt::white);
year->resize(130, 50);
year->setRect(QRect(0,0 ,130,50));
year->setAlignment(Qt::AlignCenter);
year->setTextFont(QFont("宋体", 20));
if(currentDateList.count() > 0) {
year->setText(currentDateList.at(0));
}
year->move(300,80);
//当前月份
month=new itemButton(this);
month->setTextColor(Qt::white);
month->resize(130, 50);
month->setRect(QRect(0,0 ,130,50));
month->setAlignment(Qt::AlignCenter);
month->setTextFont(QFont("宋体", 20));
剩余23页未读,继续阅读
资源评论
hu1104236178
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功