当前位置: 首页>>代码示例>>C++>>正文


C++ QDate::daysInMonth方法代码示例

本文整理汇总了C++中QDate::daysInMonth方法的典型用法代码示例。如果您正苦于以下问题:C++ QDate::daysInMonth方法的具体用法?C++ QDate::daysInMonth怎么用?C++ QDate::daysInMonth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QDate的用法示例。


在下文中一共展示了QDate::daysInMonth方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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);
}
开发者ID:Camelek,项目名称:qtmoko,代码行数:35,代码来源:monthview.cpp

示例2: accountPatient

bool AccountingForm::accountPatient(const int patientRow, const QDate date)
{
	QSqlRecord patient = m_patients->record(patientRow);
	QString filter("patient_id = ");
	filter.append(patient.value(ID).toString());

	QDate curDate;
	curDate.setDate(date.year(), date.month(), 1);
	QDate futDate;
	futDate.setDate(date.year(), date.month(), date.daysInMonth());
	QString filterString;
	filterString.append(" AND ");
	filterString.append("dateoftreat BETWEEN '");
	filterString.append(curDate.toString("yyyy-MM-dd"));
	filterString.append("' and '");
	filterString.append(futDate.toString("yyyy-MM-dd"));
	filterString.append("'");

	filter.append(filterString);
	m_treats->setFilter(filter);
	m_treats->select();

	PatientAccounter accounter(patient, *m_treats);
	accounter.account(date);

	return true;
}
开发者ID:tapdingo,项目名称:patientAccounting,代码行数:27,代码来源:AccountingForm.cpp

示例3: QDate

QList<int> tradeDateCalendar::computeFrequencyTradeMonthly(int date_, int minimumDate_, int maximumDate_)
{
    QList<int> tradeDates;

    QDate monthDayCounter = QDate::fromJulianDay(minimumDate_);
    int dayOfMonth = QDate::fromJulianDay(date_).day();

    forever
    {
        QDate monthDayComputation = monthDayCounter;
        if (monthDayComputation.day() > dayOfMonth)
            monthDayComputation = monthDayComputation.addMonths(1);

        if (dayOfMonth > monthDayComputation.daysInMonth())
        {
            monthDayComputation = monthDayComputation.addMonths(1);
            monthDayComputation = QDate(monthDayComputation.year(), monthDayComputation.month(), 1);
        }
        else
            monthDayComputation = QDate(monthDayComputation.year(), monthDayComputation.month(), dayOfMonth);

        date_ = checkTradeDate(monthDayComputation.toJulianDay(), direction_ascending);
        if (date_ > maximumDate_)
            break;

        tradeDates.append(date_);
        monthDayCounter = monthDayCounter.addMonths(1);
    }

    return tradeDates;
}
开发者ID:choff97,项目名称:mypersonalindex,代码行数:31,代码来源:tradeDateCalendar.cpp

示例4: 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;
}
开发者ID:opieproject,项目名称:opie,代码行数:34,代码来源:kdatetbl.cpp

示例5: daysShiftForMonth

int CalendarBox::Context::rowsCountForMonth(QDate month) {
	Assert(!month.isNull());
	auto daysShift = daysShiftForMonth(month);
	auto daysCount = month.daysInMonth();
	auto cellsCount = daysShift + daysCount;
	auto result = (cellsCount / kDaysInWeek);
	if (cellsCount % kDaysInWeek) ++result;
	return result;
}
开发者ID:Federated-Blockchains-Initiative,项目名称:tdesktop,代码行数:9,代码来源:calendar_box.cpp

示例6: func_eomonth

// Function: EOMONTH
Value func_eomonth(valVector args, ValueCalc *calc, FuncExtra *)
{
    // add months to date using EDATE
    Value modDate = func_edate(args, calc, 0);
    if (modDate.isError()) return modDate;

    // modDate is currently in Date format
    QDate date = modDate.asDate(calc->settings());
    date.setYMD(date.year(), date.month(), date.daysInMonth());

    return Value(date, calc->settings());
}
开发者ID:TheTypoMaster,项目名称:calligra,代码行数:13,代码来源:datetime.cpp

示例7: QWidget

ReportPage::ReportPage(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::ReportPage),
    mOppModel(Q_NULLPTR)
{
    ui->setupUi(this);

    // beginning of this month
    const QDate today = QDate::currentDate();
    ui->from->setDate(QDate(today.year(), today.month(), 1));
    // end of this month
    ui->to->setDate(QDate(today.year(), today.month(), today.daysInMonth()));
}
开发者ID:Acidburn0zzz,项目名称:FatCRM,代码行数:13,代码来源:reportpage.cpp

示例8: getDaysForSheet

	void Storage::getDaysForSheet (const QString& account, const QString& entry, int year, int month)
	{
		if (!Accounts_.contains (account))
		{
			qWarning () << Q_FUNC_INFO
					<< "Accounts_ doesn't contain"
					<< account
					<< "; raw contents"
					<< Accounts_;
			return;
		}
		if (!Users_.contains (entry))
		{
			qWarning () << Q_FUNC_INFO
					<< "Users_ doesn't contain"
					<< entry
					<< "; raw contents"
					<< Users_;
			return;
		}

		const QDate lowerDate (year, month, 1);
		const QDateTime lowerBound (lowerDate, QTime (0, 0, 0));
		const QDateTime upperBound (QDate (year, month, lowerDate.daysInMonth ()), QTime (23, 59, 59));

		GetMonthDates_.bindValue (":entry_id", Users_ [entry]);
		GetMonthDates_.bindValue (":account_id", Accounts_ [account]);
		GetMonthDates_.bindValue (":lower_date", lowerBound);
		GetMonthDates_.bindValue (":upper_date", upperBound);

		if (!GetMonthDates_.exec ())
		{
			Util::DBLock::DumpError (GetMonthDates_);
			return;
		}

		QList<int> result;
		while (GetMonthDates_.next ())
		{
			const auto date = GetMonthDates_.value (0).toDate ();
			const int day = date.day ();
			if (!result.contains (day))
				result << day;
		}
		std::sort (result.begin (), result.end ());
		emit gotDaysForSheet (account, entry, year, month, result);
	}
开发者ID:Kalarel,项目名称:leechcraft,代码行数:47,代码来源:storage.cpp

示例9: insertCalendar

void MainWindow::insertCalendar()
{
//! [1]
    QTextCursor cursor(editor->textCursor());
    cursor.movePosition(QTextCursor::Start); 

    QTextCharFormat format(cursor.charFormat());
    format.setFontFamily("Courier");
    
    QTextCharFormat boldFormat = format;
    boldFormat.setFontWeight(QFont::Bold);

    cursor.insertBlock();
    cursor.insertText(" ", boldFormat);

    QDate date = QDate::currentDate();
    int year = date.year(), month = date.month();

    for (int weekDay = 1; weekDay <= 7; ++weekDay) {
        cursor.insertText(QString("%1 ").arg(QDate::shortDayName(weekDay), 3),
            boldFormat);
    }

    cursor.insertBlock();
    cursor.insertText(" ", format);

    for (int column = 1; column < QDate(year, month, 1).dayOfWeek(); ++column) {
        cursor.insertText("    ", format);
    }

    for (int day = 1; day <= date.daysInMonth(); ++day) {
//! [1] //! [2]
        int weekDay = QDate(year, month, day).dayOfWeek();

        if (QDate(year, month, day) == date)
            cursor.insertText(QString("%1 ").arg(day, 3), boldFormat);
        else
            cursor.insertText(QString("%1 ").arg(day, 3), format);

        if (weekDay == 7) {
            cursor.insertBlock();
            cursor.insertText(" ", format);
        }
//! [2] //! [3]
    }
//! [3]
}
开发者ID:Afreeca,项目名称:qt,代码行数:47,代码来源:mainwindow.cpp

示例10: QDate

QVector<Event> EventPool::eventsByYearMonth( const int inYear, const int inMonth ) const
{
    QVector<Event> events = m_eventMap.value( inYear );
    if( events.isEmpty() )
        return events;
    QVector<Event> events_month;

    QDate firstOfMonth = QDate( inYear, inMonth, 1 );
    QDate lastOfMonth = QDate( inYear, inMonth, firstOfMonth.daysInMonth() );

    for( const Event e : events )
    {
        if( e.m_endDt.date() >= firstOfMonth and e.m_startDt.date() <= lastOfMonth )
            events_month.append( e );
    }
    return events_month;
}
开发者ID:ngc42,项目名称:Daylight,代码行数:17,代码来源:eventpool.cpp

示例11: CreateCalendar

         //Method to create calendar with an option to or not to fill data in it.
        void MonthView::CreateCalendar(bool toFillData)
         {

                 //Get weekday of 1st of selected Date
                 int day1 = QDate(StartDate.year(),StartDate.month(),1).dayOfWeek();   //SelectedDate.dayOfWeek();

                 QDate dtStart,dtEnd;

                 if(day1 == 1)//If month starts on day 1 of the week.
                 {
                         dtStart.setDate(StartDate.year(),StartDate.month(),1);

                         QDate nextMonth = StartDate.addMonths(1);

                         int endMonthDays = (42) - (StartDate.daysInMonth());

                         dtEnd.setDate(nextMonth.year(),nextMonth.month(), endMonthDays);
                 }
                 else
                 {
                         QDate prevMonth = StartDate.addMonths(-1);
                         int prevMonthDays = prevMonth.daysInMonth();

                         dtStart.setDate(prevMonth.year(),prevMonth.month(), prevMonthDays - day1 + 2 );


                         QDate nextMonth = StartDate.addMonths(1);
                         int endMonthDays = (42) - (day1 + StartDate.daysInMonth()) + 1;

                         dtEnd.setDate(nextMonth.year(),nextMonth.month(),endMonthDays);
                 }

                 ui->labelHeader->setText(QDate::shortMonthName(StartDate.month()) + ", " + QString::number(StartDate.year()));

                 SetDatesInCalendar(dtStart, dtEnd, toFillData);


         }
开发者ID:NeerajDev,项目名称:GrizzlyPeak,代码行数:39,代码来源:MonthView.cpp

示例12: setupView

void Calender::setupView(int y, int m)
{
    CalenderDay *cDay = NULL;
    QColor white(255, 255, 255);
    QColor gray(240, 240, 240);
    QString dayNrStr;
    QDate *date = new QDate(y, m, 1);

    int i, j, k, squareNr, dayNr, row, col;

    char *days[] = {
      "Monday",
      "Tuesday",
      "Wednesday",
      "Thursday",
      "Friday",
      "Saturday",
      "Sunday"
    };

    i = 0;
    k = 0;
    j = 7;
    squareNr = 1;
    dayNr = 1;
    nrOfDays = date->daysInMonth();
    firstDay = date->dayOfWeek();
    year = y;
    month = m;
    
    if (weekStarts == SUNDAY) {
      horizontalHeader()->setLabel(0, tr(days[6]));
      firstDay += 1;
      i = 1;
    }

    for (; i < j; i++, k++) {
      horizontalHeader()->setLabel(i, tr(days[k]));
    }
 
    for (row = 0; row < numRows(); row++) {
      for (col = 0; col < numCols(); col++) {
 if ((squareNr >= firstDay) && (dayNr <= nrOfDays)) {
   if ((dayLeadingZero == true) && (dayNr <= 9)) {
     dayNrStr += "0";
   }
   dayNrStr += QString::number(dayNr);
   cDay = new CalenderDay(this, QTableItem::Never, white, dayNrStr);
   dayNrStr = "";
   cDay->setDayNr(dayNr++);
   
   setItem(row, col, cDay);
 } else {
   cDay = new CalenderDay(this, QTableItem::Never, gray);
   setItem(row, col, cDay);
 }
 //setRowHeight(row, 80);    //Inte nödv. då col och rows är stretchatble
 ++squareNr;
      }
    }
}
开发者ID:andreasaronsson,项目名称:misccpp,代码行数:61,代码来源:Calender.cpp

示例13: updateData

void Calendar::updateData()
{
    if (m_days == 0 || m_weeks == 0) {
        return;
    }

    m_dayList.clear();
    m_weekList = QJsonArray();

    int totalDays = m_days * m_weeks;

    int daysBeforeCurrentMonth = 0;
    int daysAfterCurrentMonth = 0;

    QDate firstDay(m_displayedDate.year(), m_displayedDate.month(), 1);

    // If the first day is the same as the starting day then we add a complete row before it.
    if (m_firstDayOfWeek < firstDay.dayOfWeek()) {
        daysBeforeCurrentMonth = firstDay.dayOfWeek() - m_firstDayOfWeek;
    } else {
        daysBeforeCurrentMonth = days() - (m_firstDayOfWeek - firstDay.dayOfWeek());
    }

    int daysThusFar = daysBeforeCurrentMonth + m_displayedDate.daysInMonth();
    if (daysThusFar < totalDays) {
        daysAfterCurrentMonth = totalDays - daysThusFar;
    }

    if (daysBeforeCurrentMonth > 0) {
        QDate previousMonth = m_displayedDate.addMonths(-1);
        //QDate previousMonth(m_displayedDate.year(), m_displayedDate.month() - 1, 1);
        for (int i = 0; i < daysBeforeCurrentMonth; i++) {
            DayData day;
            day.isCurrent = false;
            day.dayNumber = previousMonth.daysInMonth() - (daysBeforeCurrentMonth - (i + 1));
            day.monthNumber = previousMonth.month();
            day.yearNumber = previousMonth.year();
            //      day.containsEventItems = false;
            m_dayList << day;
        }
    }

    for (int i = 0; i < m_displayedDate.daysInMonth(); i++) {
        DayData day;
        day.isCurrent = true;
        day.dayNumber = i + 1; // +1 to go form 0 based index to 1 based calendar dates
        //  day.containsEventItems = m_dayHelper->containsEventItems(i + 1);
        day.monthNumber = m_displayedDate.month();
        day.yearNumber = m_displayedDate.year();
        m_dayList << day;

    }

    if (daysAfterCurrentMonth > 0) {
        for (int i = 0; i < daysAfterCurrentMonth; i++) {
            DayData day;
            day.isCurrent = false;
            day.dayNumber = i + 1; // +1 to go form 0 based index to 1 based calendar dates
            //   day.containsEventItems = false;
            day.monthNumber = m_displayedDate.addMonths(1).month();
            day.yearNumber = m_displayedDate.addMonths(1).year();
            m_dayList << day;
        }
    }
    const int numOfDaysInCalendar = m_dayList.count();

    // Week numbers are always counted from Mondays
    // so find which index is Monday
    int mondayOffset = 0;
    if (!m_dayList.isEmpty()) {
        const DayData &data = m_dayList.at(0);
        QDate firstDay(data.yearNumber, data.monthNumber, data.dayNumber);
        // If the first day is not already Monday, get offset for Monday
        if (firstDay.dayOfWeek() != 1) {
            mondayOffset = 8 - firstDay.dayOfWeek();
        }
    }

    // Fill weeksModel with the week numbers
    for (int i = mondayOffset; i < numOfDaysInCalendar; i += 7) {
        const DayData &data = m_dayList.at(i);
        m_weekList.append(QDate(data.yearNumber, data.monthNumber, data.dayNumber).weekNumber());
    }
    emit weeksModelChanged();
    m_daysModel->update();

//    qDebug() << "---------------------------------------------------------------";
//    qDebug() << "Date obj: " << m_displayedDate;
//    qDebug() << "Month: " << m_displayedDate.month();
//    qDebug() << "m_days: " << m_days;
//    qDebug() << "m_weeks: " << m_weeks;
//    qDebug() << "Days before this month: " << daysBeforeCurrentMonth;
//    qDebug() << "Days after this month: " << daysAfterCurrentMonth;
//    qDebug() << "Days in current month: " << m_displayedDate.daysInMonth();
//    qDebug() << "m_dayList size: " << m_dayList.count();
//    qDebug() << "---------------------------------------------------------------";
}
开发者ID:KDE,项目名称:plasma-framework,代码行数:97,代码来源:calendar.cpp

示例14: seasonFile

//
// Manage the seasons array
//
void
Seasons::readSeasons()
{
    QFile seasonFile(home.absolutePath() + "/seasons.xml");
    QXmlInputSource source( &seasonFile );
    QXmlSimpleReader xmlReader;
    SeasonParser handler;
    xmlReader.setContentHandler(&handler);
    xmlReader.setErrorHandler(&handler);
    xmlReader.parse( source );
    seasons = handler.getSeasons();

    Season season;
    QDate today = QDate::currentDate();
    QDate eom = QDate(today.year(), today.month(), today.daysInMonth());

    // add Default Date Ranges
    season.setName(tr("All Dates"));
    season.setType(Season::temporary);
    season.setStart(QDate::currentDate().addYears(-50));
    season.setEnd(QDate::currentDate().addYears(50));
    season.setId(QUuid("{00000000-0000-0000-0000-000000000001}"));
    seasons.append(season);

    season.setName(tr("This Year"));
    season.setType(Season::temporary);
    season.setStart(QDate(today.year(), 1,1));
    season.setEnd(QDate(today.year(), 12, 31));
    season.setId(QUuid("{00000000-0000-0000-0000-000000000002}"));
    seasons.append(season);

    season.setName(tr("This Month"));
    season.setType(Season::temporary);
    season.setStart(QDate(today.year(), today.month(),1));
    season.setEnd(eom);
    season.setId(QUuid("{00000000-0000-0000-0000-000000000003}"));
    seasons.append(season);

    season.setName(tr("This Week"));
    season.setType(Season::temporary);
    // from Mon-Sun
    QDate wstart = QDate::currentDate();
    wstart = wstart.addDays(Qt::Monday - wstart.dayOfWeek());
    QDate wend = wstart.addDays(6); // first day + 6 more
    season.setStart(wstart);
    season.setEnd(wend);
    season.setId(QUuid("{00000000-0000-0000-0000-000000000004}"));
    seasons.append(season);

    season.setName(tr("Last 7 days"));
    season.setType(Season::temporary);
    season.setStart(today.addDays(-6)); // today plus previous 6
    season.setEnd(today);
    season.setId(QUuid("{00000000-0000-0000-0000-000000000005}"));
    seasons.append(season);

    season.setName(tr("Last 14 days"));
    season.setType(Season::temporary);
    season.setStart(today.addDays(-13));
    season.setEnd(today);
    season.setId(QUuid("{00000000-0000-0000-0000-000000000006}"));
    seasons.append(season);

    season.setName(tr("Last 21 days"));
    season.setType(Season::temporary);
    season.setStart(today.addDays(-20));
    season.setEnd(today);
    season.setId(QUuid("{00000000-0000-0000-0000-000000000011}"));
    seasons.append(season);

    season.setName(tr("Last 28 days"));
    season.setType(Season::temporary);
    season.setStart(today.addDays(-27));
    season.setEnd(today);
    season.setId(QUuid("{00000000-0000-0000-0000-000000000007}"));
    seasons.append(season);

    season.setName(tr("Last 2 months"));
    season.setType(Season::temporary);
    season.setEnd(today);
    season.setStart(today.addMonths(-2));
    season.setId(QUuid("{00000000-0000-0000-0000-000000000008}"));
    seasons.append(season);

    season.setName(tr("Last 3 months"));
    season.setType(Season::temporary);
    season.setEnd(today);
    season.setStart(today.addMonths(-3));
    season.setId(QUuid("{00000000-0000-0000-0000-000000000011}"));
    seasons.append(season);

    season.setName(tr("Last 6 months"));
    season.setType(Season::temporary);
    season.setEnd(today);
    season.setStart(today.addMonths(-6));
    season.setId(QUuid("{00000000-0000-0000-0000-000000000009}"));
    seasons.append(season);
//.........这里部分代码省略.........
开发者ID:lawnboyy,项目名称:GoldenCheetah,代码行数:101,代码来源:Season.cpp

示例15: generateMonthTitle

QString CrCalendar::generateMonthTitle() {
    QString str;

    QDate daysIterator;
    QDate actualMonth = QDate(_dateFirst.year(),_dateFirst.month(),1);
    int daysCount = 0;

    if(_dateFirst.month() == _dateLast.month() && _dateFirst.year() == _dateLast.year()) {
        str += "<td colspan=\""+ QString::number(_dateFirst.daysTo(_dateLast.addDays(1)))+"\"";;
        str += " class=\""+ Cell::getCssClassAsString(Cell::month_title) +"\">";
        str += getMonthString(_dateFirst.month());
        str += " ";
        str += _dateFirst.toString("yyyy");
        str += "</td>\n";
    } else {
        for(daysIterator = _dateFirst; daysIterator.operator <=(_dateLast); daysIterator = daysIterator.addDays(1)) {

            if(daysIterator.operator ==(QDate(daysIterator.year(), daysIterator.month(),daysIterator.daysInMonth()))
                    || daysIterator.operator ==(_dateLast)) {

                str += "<td colspan=\""+ QString::number(++daysCount) +"\"";
                str += " class=\""+ Cell::getCssClassAsString(Cell::month_title) + "\">";
                str += getMonthString(actualMonth.month());
                str += " ";
                str += actualMonth.toString("yyyy");

                str += "</td>\n";

                daysCount = 0;
                actualMonth = actualMonth.addMonths(1);
            } else {
                daysCount++;
            }
        }
    }

    return str;
}
开发者ID:keresan,项目名称:calendarRenderer_v1,代码行数:38,代码来源:crcalendar.cpp


注:本文中的QDate::daysInMonth方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。