16,203
社区成员
发帖
与我相关
我的任务
分享
signals:
void dateChanged(int w,int x,int y,int z);
private slots:
void emitDate();
connect(this,SIGNAL(selectionChanged()),this,SLOT(emitDate()));
void MyCalendar::emitDate()
{
//更改选中日期信号
QDate cDate;
int cYear;
int cMonth;
int cDay;
cDate = selectedDate();
cYear=cDate.year();
cMonth=cDate.month();
cDay=cDate.day();
QDate firstDay(2010,12,31);
QDate today(cYear,cMonth,cDay);
int cdayId=firstDay.daysTo(today);
emit dateChanged(cYear,cMonth,cDay,cdayId);
}
private slots:
void getDate(int i,int m,int n,int o);
connect(calendar,SIGNAL(dateChanged(int,int,int,int)),this,SLOT(getDate(int,int,int,int)));
void Window::getDate(int i, int m, int n ,int o)
{
//右侧小日历日期更改槽函数
int gYear=i;
int gMonth=m;
int gDay=n;
int gDayId=o;
...
}
void cursorPositionChanged ( int old, int new )
void editingFinished ()
void returnPressed ()
void selectionChanged ()
void textChanged ( const QString & text )
void textEdited ( const QString & text )
int main(int argc ,char *argv[])
{
QApplication app(argc,argv);
QWidget* widget = new QWidget;
QListWidget* listWidget = new QListWidget;
QVBoxLayout* layout = new QVBoxLayout;
QStringList readDate;
QStringList dateList;
dateList<<"gfsdj"
<<"sghfjs"
<<"s2222";
<<"shdkahsd&skdfh&lskdhf&sdlkfh93"
<<"786ri&d89fys&skdfh87w"
<<"sdhkf sjd89f7"
qDebug()<<dateList;
QFile file_w("/home/xmltest/data.txt");
if(!file_w.open(QIODevice::Append | QIODevice::Text))
{
qDebug("fail");
}
QTextStream tt(&file_w);
for(int i=0;i<3;i++)
{
tt<<dateList.value(i)<<endl;
}
file_w.close();
QFile file_r("/home/xmltest/data.txt");
if (!file_r.open(QIODevice::ReadOnly | QIODevice::Text))
{
qDebug("fail");
}
while (!file_r.atEnd())
{
QByteArray line = file_r.readLine();
readDate.clear();
readDate=QString(line).split("&");
if(readDate.size()==3)
{
QString tmp =readDate.at(0);
QString name=readDate.at(1);
QString time=readDate.at(2);
listWidget->addItem(QString("%1 %2 %3").arg(tmp,name,time));
}
}
file_r.close();
layout->addWidget(listWidget);
widget->setLayout(layout);
widget->show();
}