// 将int, short, long, float, double 转换为 QString 类型 QString &QString::setNum(int n, int base = 10); [static] QString QString::number(long n, int base = 10);
// 将 QString 转换为 int, short, long, float, double 类型 intQString::toInt(bool *ok = Q_NULLPTR, int base = 10)const; shortQString::toShort(bool *ok = Q_NULLPTR, int base = 10)const; longQString::toLong(bool *ok = Q_NULLPTR, int base = 10)const floatQString::toFloat(bool *ok = Q_NULLPTR)const; doubleQString::toDouble(bool *ok = Q_NULLPTR)const;
// 得到日期对象中的年/月/日 intQDate::year()const; intQDate::month()const; intQDate::day()const; voidQDate::getDate(int *year, int *month, int *day)const;
//转字符串时必须用下面这些参数的组合,比如"yy-M-d" /* d - The day as a number without a leading zero (1 to 31) dd - The day as a number with a leading zero (01 to 31) ddd - The abbreviated localized day name (e.g. 'Mon' to 'Sun'). Uses the system locale to localize the name, i.e. QLocale::system(). dddd - The long localized day name (e.g. 'Monday' to 'Sunday'). Uses the system locale to localize the name, i.e. QLocale::system(). M - The month as a number without a leading zero (1 to 12) MM - The month as a number with a leading zero (01 to 12) MMM - The abbreviated localized month name (e.g. 'Jan' to 'Dec'). Uses the system locale to localize the name, i.e. QLocale::system(). MMMM - The long localized month name (e.g. 'January' to 'December'). Uses the system locale to localize the name, i.e. QLocale::system(). yy - The year as a two digit number (00 to 99) yyyy - The year as a four digit number. If the year is negative, a minus sign is prepended, making five characters. */ QString QDate::toString(const QString &format)const;
// 构造函数 QTime::QTime(); /* h ==> 取值范围: 0 ~ 23 m and s ==> 取值范围: 0 ~ 59 ms ==> 取值范围: 0 ~ 999 */ QTime::QTime(int h, int m, int s = 0, int ms = 0);
// 公共成员函数 // Returns true if the set time is valid; otherwise returns false. boolQTime::setHMS(int h, int m, int s, int ms = 0); QTime QTime::addSecs(int s)const; QTime QTime::addMSecs(int ms)const;
// 示例代码 QTime n(14, 0, 0); // n == 14:00:00 QTime t; t = n.addSecs(70); // t == 14:01:10
// 从时间对象中取出 时/分/秒/毫秒 // Returns the hour part (0 to 23) of the time. Returns -1 if the time is invalid. intQTime::hour()const; // Returns the minute part (0 to 59) of the time. Returns -1 if the time is invalid. intQTime::minute()const; // Returns the second part (0 to 59) of the time. Returns -1 if the time is invalid. intQTime::second()const; // Returns the millisecond part (0 to 999) of the time. Returns -1 if the time is invalid. intQTime::msec()const;
// 时间格式化 /* -- 时 -- h ==> The hour without a leading zero (0 to 23 or 1 to 12 if AM/PM display) hh ==> The hour with a leading zero (00 to 23 or 01 to 12 if AM/PM display) H ==> The hour without a leading zero (0 to 23, even with AM/PM display) HH ==> The hour with a leading zero (00 to 23, even with AM/PM display) -- 分 -- m ==> The minute without a leading zero (0 to 59) mm ==> The minute with a leading zero (00 to 59) -- 秒 -- s ==> The whole second, without any leading zero (0 to 59) ss ==> The whole second, with a leading zero where applicable (00 to 59) -- 毫秒 -- zzz ==> The fractional part of the second, to millisecond precision, including trailing zeroes where applicable (000 to 999). -- 上午或者下午 AP or A ==> 使用AM/PM(大写) 描述上下午, 中文系统显示汉字 ap or a ==> 使用am/pm(小写) 描述上下午, 中文系统显示汉字 */ QString QTime::toString(const QString &format)const;