本文整理汇总了C++中QDate::setYMD方法的典型用法代码示例。如果您正苦于以下问题:C++ QDate::setYMD方法的具体用法?C++ QDate::setYMD怎么用?C++ QDate::setYMD使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDate
的用法示例。
在下文中一共展示了QDate::setYMD方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: kdDebug
bool
KDateTable::setDate(const QDate& date_)
{
bool changed=false;
QDate temp;
// -----
if(!date_.isValid())
{
kdDebug() << "KDateTable::setDate: refusing to set invalid date." << endl;
return false;
}
if(date!=date_)
{
date=date_;
changed=true;
}
temp.setYMD(date.year(), date.month(), 1);
firstday=temp.dayOfWeek();
if(firstday==1) firstday=8;
numdays=date.daysInMonth();
if(date.month()==1)
{ // set to december of previous year
temp.setYMD(date.year()-1, 12, 1);
} else { // set to previous month
temp.setYMD(date.year(), date.month()-1, 1);
}
numDaysPrevMonth=temp.daysInMonth();
if(changed)
{
repaintContents(false);
}
emit(dateChanged(date));
return true;
}
示例2: daysToNext
int AddressBookPluginWidget::daysToNext( const QDate &date )
{
// Calculate how many days until the birthday/anniversary
// We have to set the correct year to calculate the day diff...
QDate destdate;
destdate.setYMD( QDate::currentDate().year(), date.month(),
date.day() );
if ( QDate::currentDate().daysTo(destdate) < 0 )
destdate.setYMD( QDate::currentDate().year()+1,
destdate.month(), destdate.day() );
return QDate::currentDate().daysTo(destdate);
}
示例3: converter
/*
* This function will convert a string I.e. 25.06.1978 into a QDate and pass the new
* object back.
* This will be used to read strings from XML files and enter the QDate into the students DOB.
* Also this will be used to help Creator save and store dates.
*/
QDate Dater::converter(QString ndate) {
QStringList ldob;
QDate dob;
int year, month, day;
year = month = day = 1;
// some people will separate the date and time using . or / or - this trys to solve this problem
if ( ndate.contains( "." ) )
ldob = QStringList::split( ".", ndate );
if ( ndate.contains( "/" ) )
ldob = QStringList::split( "/", ndate );
if ( ndate.contains( "-" ) )
ldob = QStringList::split( "-", ndate );
QStringList::Iterator it = ldob.begin();
day = atoi(*it); it++;
month = atoi(*it); it++;
year = atoi(*it);
if ( month <1 || day <1 || month > 12 || day > 31 ) {
QMessageBox::critical(0, "infobot", "Error inserting date\n"
"contact your vendor quoting error code AFQW251\n"
"The system will now save and close, sorry for any inconveniance");
exit( AFQW251 );
}
dob.setYMD( year, month, day );
return dob;
}
示例4: QCalendarWidget
MonthView::MonthView(QWidget *parent, const QCategoryFilter& c, QSet<QPimSource> set)
: QCalendarWidget(parent)
{
setObjectName("monthview");
setVerticalHeaderFormat(NoVerticalHeader);
setFirstDayOfWeek( Qtopia::weekStartsOnMonday() ? Qt::Monday : Qt::Sunday );
QDate start = QDate::currentDate();
start.setYMD(start.year(), start.month(), 1);
QDate end = start.addDays(start.daysInMonth() - 1);
model = new QOccurrenceModel(QDateTime(start, QTime(0, 0, 0)), QDateTime(end.addDays(1), QTime(0, 0)), this);
if (set.count() > 0)
model->setVisibleSources(set);
model->setCategoryFilter(c);
connect(model, SIGNAL(modelReset()), this, SLOT(resetFormatsSoon()));
connect(this, SIGNAL(currentPageChanged(int,int)), this, SLOT(updateModelRange(int,int)));
// Since we don't know if we'll get a model reset from the model
// at startup, force a timer
dirtyTimer = new QTimer();
dirtyTimer->setSingleShot(true);
dirtyTimer->setInterval(0);
connect(dirtyTimer, SIGNAL(timeout()), this, SLOT(resetFormats()));
resetFormatsSoon();
// XXX find the QCalendarView class so we can handle Key_Back properly :/
// [this comes from qtopiaapplication.cpp]
QWidget *table = findChild<QWidget*>("qt_calendar_calendarview");
if (table)
table->installEventFilter(this);
}
示例5: range
bool DialogSearch::range(QDate &begin, QDate &end, QString &own)
{
QDate start;
// Default search from 1 of the current month to today
start.setYMD(QDate::currentDate().year(), QDate::currentDate().month(), 1);
ui->dateEditStart->setDate(start);
ui->dateEditEnd->setDate(QDate::currentDate());
if (this->exec() == QDialog::Accepted) {
/*QTime workingTime;
QTime overTime;
int days;
BadgeData data;
QMap <QString, QTime> activities;
ok = true;*/
begin = ui->dateEditStart->date();
end = ui->dateEditEnd->date();
own = ui->lineEditOwn->text();
return true;
}
return false;
}
示例6: setSeries
void DcmtkSeriesListWidget::setSeries(std::vector<voreen::DcmtkSeriesInfo>& list) {
// table->clear();
table->setSortingEnabled(false); // disable sorting temporarly for inserting new items
std::vector<voreen::DcmtkSeriesInfo>::iterator theIterator;
int c = 0;
table->setRowCount(static_cast<int>(list.size()));
QDate date;
std::string temp;
for (theIterator = list.begin(); theIterator != list.end(); theIterator++) {
QTableWidgetItem* it = new QTableWidgetItem(QString::fromStdString((*theIterator).uid_));
it->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
table->setItem(c, 0, it);
it = new QTableWidgetItem(QString::fromStdString((*theIterator).numImages_));
it->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
table->setItem(c, 1, it);
it = new QTableWidgetItem(QString::fromStdString((*theIterator).patientsName_));
it->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
table->setItem(c, 2, it);
it = new QTableWidgetItem(QString::fromStdString((*theIterator).patientId_));
it->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
table->setItem(c, 3, it);
temp = (*theIterator).studyDate_;
if (temp.length() == 8) {
int y = (temp[0]-'0')*1000+(temp[1]-'0')*100+(temp[2]-'0')*10+(temp[3]-'0');
int m = (temp[4]-'0')*10+(temp[5]-'0');
int d = (temp[6]-'0')*10+(temp[7]-'0');
date.setYMD(y,m,d);
it = new QTableWidgetItemDate(date);
}
else
it = new QTableWidgetItem(QString::fromStdString(temp));
it->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
table->setItem(c, 4, it);
temp = (*theIterator).studyTime_;
if (temp.length() >= 6) {
temp.insert(4,":");
temp.insert(2,":");
}
// else
it = new QTableWidgetItem(QString::fromStdString(temp));
it->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
table->setItem(c, 5, it);
it = new QTableWidgetItem(QString::fromStdString((*theIterator).modality_));
it->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
table->setItem(c, 6, it);
it = new QTableWidgetItem(QString::fromStdString((*theIterator).description_));
it->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
table->setItem(c, 7, it);
++c;
}
table->setSortingEnabled(true); // re-enable sorting
}
示例7: LogEventL
void NotifyProvider::LogEventL(const CLogEvent &event)
{
// store new call
QString number=QString::fromRawData(reinterpret_cast<const QChar*>(event.Number().Ptr()),event.Number().Length());
QString direction=QString::fromRawData(reinterpret_cast<const QChar*>(event.Direction().Ptr()),event.Direction().Length());
QString description=QString::fromRawData(reinterpret_cast<const QChar*>(event.Description().Ptr()),event.Description().Length());
if (description.contains("Voice call")&&direction.contains("Missed call"))
{
TTime times=event.Time();
RTz tzsession;
tzsession.Connect();
tzsession.ConvertToLocalTime(times);
tzsession.Close();
TDateTime dts=times.DateTime();
QDate d; QTime t;
d.setYMD(dts.Year(),dts.Month()+1,dts.Day()+1);
t.setHMS(dts.Hour(),dts.Minute(),dts.Second());
QDateTime dt; dt.setDate(d); dt.setTime(t);
dt=dt.toLocalTime();
QString time=dt.toString("d.M.yy hh:mm");
TNotifyInfo info;
info.time=time;
info.timeStamp=dt;
info.sender=number;
info.text=findContact(number);
info.id=-1;
info.type=EMissedCall;
iNotifiers.insert(0,info);
qDebug()<<"store call from"<<info.sender;
prepareNotifier(EMissedCall);
}
}
示例8: fill
void MoreInfo::fill()
{
ICQUserData *data = m_data;
if (data == NULL)
data = &m_client->data.owner;
edtHomePage->setText(data->Homepage.str());
initCombo(cmbGender, data->Gender.toULong(), genders);
if (spnAge->text() == "0")
spnAge->setSpecialValueText(QString::null);
if (data->BirthYear.toULong()>0 && data->BirthMonth.toULong()>0 && data->BirthDay.toULong()>0) {
QDate date;
date.setYMD(data->BirthYear.toULong(), data->BirthMonth.toULong(), data->BirthDay.toULong());
edtDate->setDate(date);
birthDayChanged();
}
unsigned l = data->Language.toULong();
char l1 = (char)(l & 0xFF);
l = l >> 8;
char l2 = (char)(l & 0xFF);
l = l >> 8;
char l3 = (char)(l & 0xFF);
initCombo(cmbLang1, l1, languages);
initCombo(cmbLang2, l2, languages);
initCombo(cmbLang3, l3, languages);
setLang(0);
urlChanged(edtHomePage->text());
}
示例9: QDialog
//------------------------------------------------------------
tke_Dialog_filtr_borjnykiv::tke_Dialog_filtr_borjnykiv(QWidget *parent)
: QDialog(parent)
{
ui.setupUi(this);
QSqlQuery *query = new QSqlQuery();
query->exec("SELECT id, Vulycia & ' ' & Bud_num FROM budynky ORDER BY Vulycia & ' ' & Bud_num");
ui.comboBox_budynok->clear();
budList.clear();
budList << 0;
ui.comboBox_budynok->addItem("”с≥ будинки");
while(query->next()){
ui.comboBox_budynok->addItem(query->value(1).toString());
budList << query->value(0).toInt();
}
setWindowFlags ( windowFlags() | Qt::WindowStaysOnTopHint );
QDate date;
date = QDate::currentDate();
ui.dateEdit_poch->setMaximumDate(date);
ui.dateEdit_kinc->setDate(date);
ui.dateEdit_kinc->setMaximumDate(date);
date.setYMD(2003, 1, 1);
ui.dateEdit_poch->setMinimumDate(date);
ui.dateEdit_poch->setDate(date);
ui.dateEdit_kinc->setMinimumDate(date);
delete query;
}
示例10: stamp2TS
QDateTime stamp2TS(const QString &ts)
{
if(ts.length() != 17)
return QDateTime();
int year = ts.mid(0,4).toInt();
int month = ts.mid(4,2).toInt();
int day = ts.mid(6,2).toInt();
int hour = ts.mid(9,2).toInt();
int min = ts.mid(12,2).toInt();
int sec = ts.mid(15,2).toInt();
QDate xd;
xd.setYMD(year, month, day);
if(!xd.isValid())
return QDateTime();
QTime xt;
xt.setHMS(hour, min, sec);
if(!xt.isValid())
return QDateTime();
return QDateTime(xd, xt);
}
示例11: ASN1_UTCTIME_QDateTime
// This code is mostly taken from OpenSSL v0.9.5a
// by Eric Young
QDateTime ASN1_UTCTIME_QDateTime(ASN1_UTCTIME *tm, int *isGmt) {
QDateTime qdt;
char *v;
int gmt=0;
int i;
int y=0,M=0,d=0,h=0,m=0,s=0;
QDate qdate;
QTime qtime;
i = tm->length;
v = (char *)tm->data;
if (i < 10) goto auq_err;
if (v[i-1] == 'Z') gmt=1;
for (i=0; i<10; ++i)
if ((v[i] > '9') || (v[i] < '0')) goto auq_err;
y = (v[0]-'0')*10+(v[1]-'0');
if (y < 50) y+=100;
M = (v[2]-'0')*10+(v[3]-'0');
if ((M > 12) || (M < 1)) goto auq_err;
d = (v[4]-'0')*10+(v[5]-'0');
h = (v[6]-'0')*10+(v[7]-'0');
m = (v[8]-'0')*10+(v[9]-'0');
if ( (v[10] >= '0') && (v[10] <= '9') &&
(v[11] >= '0') && (v[11] <= '9'))
s = (v[10]-'0')*10+(v[11]-'0');
// localize the date and display it.
qdate.setYMD(y+1900, M, d);
qtime.setHMS(h,m,s);
qdt.setDate(qdate); qdt.setTime(qtime);
auq_err:
if (isGmt) *isGmt = gmt;
return qdt;
}
示例12: todayStart
/******************************************************************************
* Return a list of events for birthdays chosen.
*/
QList<KAEvent> BirthdayDlg::events() const
{
QList<KAEvent> list;
QModelIndexList indexes = mListView->selectionModel()->selectedRows();
int count = indexes.count();
if (!count)
return list;
QDate today = KDateTime::currentLocalDate();
KDateTime todayStart(today, KDateTime::ClockTime);
int thisYear = today.year();
int reminder = mReminder->minutes();
const BirthdaySortModel* model = static_cast<const BirthdaySortModel*>(indexes[0].model());
for (int i = 0; i < count; ++i)
{
BirthdayModel::Data* data = model->rowData(indexes[i]);
if (!data)
continue;
QDate date = data->birthday;
date.setYMD(thisYear, date.month(), date.day());
if (date <= today)
date.setYMD(thisYear + 1, date.month(), date.day());
KAEvent event(KDateTime(date, KDateTime::ClockTime),
mPrefix->text() + data->name + mSuffix->text(),
mFontColourButton->bgColour(), mFontColourButton->fgColour(),
mFontColourButton->font(), KAEventData::MESSAGE, mLateCancel->minutes(),
mFlags, true);
float fadeVolume;
int fadeSecs;
float volume = mSoundPicker->volume(fadeVolume, fadeSecs);
event.setAudioFile(mSoundPicker->file().prettyUrl(), volume, fadeVolume, fadeSecs);
QList<int> months;
months.append(date.month());
event.setRecurAnnualByDate(1, months, 0, KARecurrence::defaultFeb29Type(), -1, QDate());
event.setRepetition(mSubRepetition->repetition());
event.setNextOccurrence(todayStart);
if (reminder)
event.setReminder(reminder, false);
if (mSpecialActionsButton)
event.setActions(mSpecialActionsButton->preAction(),
mSpecialActionsButton->postAction(),
mSpecialActionsButton->cancelOnError());
event.endChanges();
list.append(event);
}
return list;
}
示例13: todayStart
/******************************************************************************
* Return a list of events for birthdays chosen.
*/
QVector<KAEvent> BirthdayDlg::events() const
{
QVector<KAEvent> list;
QModelIndexList indexes = mListView->selectionModel()->selectedRows();
int count = indexes.count();
if (!count)
return list;
QDate today = KDateTime::currentLocalDate();
KDateTime todayStart(today, KDateTime::Spec(KDateTime::ClockTime));
int thisYear = today.year();
int reminder = mReminder->minutes();
for (int i = 0; i < count; ++i)
{
const QModelIndex nameIndex = indexes.at(i).model()->index(indexes.at(i).row(), 0);
const QModelIndex birthdayIndex = indexes.at(i).model()->index(indexes.at(i).row(), 1);
const QString name = nameIndex.data(Qt::DisplayRole).toString();
QDate date = birthdayIndex.data(BirthdayModel::DateRole).toDate();
date.setYMD(thisYear, date.month(), date.day());
if (date <= today)
date.setYMD(thisYear + 1, date.month(), date.day());
KAEvent event(KDateTime(date, KDateTime::Spec(KDateTime::ClockTime)),
mPrefix->text() + name + mSuffix->text(),
mFontColourButton->bgColour(), mFontColourButton->fgColour(),
mFontColourButton->font(), KAEvent::MESSAGE, mLateCancel->minutes(),
mFlags, true);
float fadeVolume;
int fadeSecs;
float volume = mSoundPicker->volume(fadeVolume, fadeSecs);
int repeatPause = mSoundPicker->repeatPause();
event.setAudioFile(mSoundPicker->file().toDisplayString(), volume, fadeVolume, fadeSecs, repeatPause);
QVector<int> months(1, date.month());
event.setRecurAnnualByDate(1, months, 0, KARecurrence::defaultFeb29Type(), -1, QDate());
event.setRepetition(mSubRepetition->repetition());
event.setNextOccurrence(todayStart);
if (reminder)
event.setReminder(reminder, false);
if (mSpecialActionsButton)
event.setActions(mSpecialActionsButton->preAction(),
mSpecialActionsButton->postAction(),
mSpecialActionsButton->options());
event.endChanges();
list.append(event);
}
return list;
}
示例14: testFollowUp
void testFollowUp(){
FollowUpRecord f;
f.setConsultationRecordId(1);
f.setDetails(QString("Details string"));
QDate qd;
QTime qt;
QDateTime d;
qd.setYMD(2000,1,1);
qt.setHMS(12,12,12);
d.setDate(qd);
d.setTime(qt);
f.setDueDateTime(d);
f.setStatus(FollowUpRecord::PENDING);
if(f.getConsultationRecordId() != 1){
qDebug() << "ERROR WITH /followuprecord/consultationrecordid";
}
if(QString::compare(QString("Details string"),f.getDetails())!=0){
qDebug() << "ERROR WITH /followuprecord/details TEST";
}
if(f.getDueDateTime().date().day() != 1){
qDebug() << "ERROR WITH /followuprecord/datetime/day TEST";
}
if(f.getDueDateTime().date().month() != 1){
qDebug() << "ERROR WITH /followuprecord/datetime/month TEST";
}
if(f.getDueDateTime().date().year() != 2000){
qDebug() << "ERROR WITH /followuprecord/datetime/year TEST";
}
if(f.getDueDateTime().time().hour() != 12){
qDebug() << "ERROR WITH /followuprecord/datetime/hour TEST";
}
if(f.getDueDateTime().time().minute() != 12){
qDebug() << "ERROR WITH /followuprecord/datetime/minute TEST";
}
if(f.getDueDateTime().time().second() != 12){
qDebug() << "ERROR WITH /followuprecord/datetime/second TEST";
}
if(f.getStatus() != FollowUpRecord::PENDING){
qDebug() <<"ERROR WITH /followuprecord/status";
}
}
示例15: toQDateTime
const QDateTime ADBColumn::toQDateTime(int useBackup)
{
if (intDataType != FIELD_TYPE_DATETIME &&
intDataType != FIELD_TYPE_TIMESTAMP
) ADBLogMsg(LOG_WARNING, "ADBColumn::toQDate(%d) - Warning! Column is not a date", intColumnNo);
QDateTime retVal;
QDate tmpDate;
QTime tmpTime;
QString tmpQStr;
if (useBackup) tmpQStr = intOldData;
else tmpQStr = intData;
if (tmpQStr.length() == 14) {
// Its a time stamp in the form YYYYMMDDHHMMSS
tmpDate.setYMD(
tmpQStr.mid(0,4).toInt(),
tmpQStr.mid(4,2).toInt(),
tmpQStr.mid(6,2).toInt()
);
tmpTime.setHMS(
tmpQStr.mid( 8,2).toInt(),
tmpQStr.mid(10,2).toInt(),
tmpQStr.mid(12,2).toInt()
);
} else {
// Its a datetime in the form YYYY-MM-DD HH:MM:SS
tmpDate.setYMD(
tmpQStr.mid(0,4).toInt(),
tmpQStr.mid(5,2).toInt(),
tmpQStr.mid(8,2).toInt()
);
tmpTime.setHMS(
tmpQStr.mid(11,2).toInt(),
tmpQStr.mid(14,2).toInt(),
tmpQStr.mid(17,2).toInt()
);
}
retVal.setDate(tmpDate);
retVal.setTime(tmpTime);
return (const QDateTime) retVal;
}