将QDate转换为Qstring? [英] Convert QDate to Qstring?

查看:937
本文介绍了将QDate转换为Qstring?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在将QDate转换为QString时遇到麻烦。请参见下面的代码:

I have trouble converting QDate to QString. See the code below:

cout << QString("\nBooking Date: %1").arg(QDate::toString(this->getBookingDate() &YYYY.mm.dd)

当我尝试编译它时,会给我:

When I try to compile this it gives me:

‘YYYY’ was not declared in this scope

但文档说:

将日期作为字符串返回。format参数确定结果字符串的格式...,然后继续列出格式字符串。

"Returns the date as a string. The format parameter determines the format of the result string..." and goes on to list the format strings.

我是Qt的新手,所以如果我错过了明显的东西,请原谅。

I am new to Qt so if I am missing the obvious please excuse the ignorance.

推荐答案

您要 this-> getBookingDate()。toString( yyyy.MM.dd)。有关更多信息,请阅读文档

You want this->getBookingDate().toString("yyyy.MM.dd"). For further info, read the documentation.

这篇关于将QDate转换为Qstring?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆