我的QDateTime(QDate,QTime)构造函数总是创建" 1 Januari 1970 00:00:00"

时间:2014-08-08 07:11:37

标签: c++ qt debugging bug-reporting

Debug info

我的QDateTime构造函数有一个奇怪的问题,我在Windows上使用Qt creator 3.1.1创建了一个日历程序,它基于Qt 5.2.1(MSVC 2010, 32位)

正如您在调试器信息中看到的那样,month = 9year = 2014

仍然执行以下代码

void GUICalendar::monthUpdated(int year, int month)
{
    QDateTime begin = QDateTime(QDate(year, month, 1), QTime(0,0,0));
    QDateTime end = QDateTime(QDate(year, month, begin.date().daysInMonth()), QTime(23,59,59));

    QList<AppointmentSolo*> soloList = m_calendar->AppointmentSoloBetween(begin, end);
    QList<AppointmentRepeat*> repeatList = m_calendar->AppointmentRepeatBetween(begin, end);
    QList<TodoBaseTask*> todoList = m_calendar->TodoTasksBetween(begin, end);

    m_dayView->update(soloList, repeatList, todoList);
}

这就是发生的事情

begin = jan 1 00:00:00 1970
end = jan 1 00:00:00 1970

我不确定为什么会发生这种情况,因为begin中我的QDate应该sep 1 2014仍然会被更改为jan 1 1970

我已经坚持了这个问题差不多一个小时了,所以如果有人在这里解释我做错了什么或为什么会这样,我真的很感激。

0 个答案:

没有答案