我无法将 QDate 转换为 QString。请看下面的代码:
cout << QString("\nBooking Date: %1").arg(QDate::toString(this->getBookingDate() &YYYY.mm.dd)
当我尝试编译它时,它会给我:
‘YYYY’ was not declared in this scope
但是文档说:
“以字符串形式返回日期。格式参数确定结果字符串的格式...”并继续列出格式字符串。
我是 Qt 的新手,所以如果我遗漏了显而易见的内容,请原谅我的无知。
最佳答案
您需要 this->getBookingDate().toString("yyyy.MM.dd")
。有关详细信息,请阅读 documentation .
关于c++ - 将 QDate 转换为 Qstring?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9726430/