方法一
int nTime;
QString str = "100小时";
QRegExp rx("(\\d+)");
int pos = 0;
while ((pos = rx.indexIn(str, pos)) != -1) {
nTime= rx.cap(0).toInt();
pos += rx.matchedLength();
}
qDebug( )<<nTime;
方法二
char buf[32] = {0};
sscanf("20小时","%[0-9]",buf);
qDebug()<<"num is "<< atoi(buf);