在Qt中向QTime和QDateTime添加时间的问题
我没有时间添加功能来工作。我用的是Qt4。这是代码片段,它产生两个相同的时间,而不是相差 100 秒。
void main()
{
QTextStream out (stdout);
QTime t = QTime::currentTime();
out << t.toString("hh:mm:ss") << " -> ";
t.addSecs(100);
out << t.toString("hh:mm:ss");
}
I can't get time adding functions to work. I'm using Qt4. Here is the code snippet, which produces two identical times instead of 100s different.
void main()
{
QTextStream out (stdout);
QTime t = QTime::currentTime();
out << t.toString("hh:mm:ss") << " -> ";
t.addSecs(100);
out << t.toString("hh:mm:ss");
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
addSecs() 返回一个已调整的新 QTime 对象。它不会影响“this”对象。
请注意,文档中的成员函数是“const”。
addSecs() returns a new QTime object that has been adjusted. It doesn't affect the 'this' object.
Note that the member function is 'const' in the docs.