小编Jel*_*ser的帖子

必须使用 '.*' 或 '->*' 在 'lessThan (...)' 中调用指向成员函数的指针,例如 '(... ->* lessThan) (...)'

我正在尝试根据 QDateTime 对 QList 进行排序,但出现以下错误:

must use '.*' or '->*' to call pointer-to-member function in 'lessThan (...)', e.g. '(... ->* lessThan) (...)'
 if (lessThan(*end, *start))
                          ^
Run Code Online (Sandbox Code Playgroud)

排序功能:

bool sortRecord(Record left, Record right){
    return left.getArrival().getDate() < right.getArrival().getDate();
}
Run Code Online (Sandbox Code Playgroud)

函数是这样调用的:

qSort(recordList.begin(), recordList.end(), sortRecord);
Run Code Online (Sandbox Code Playgroud)

Record 中到达的 getter 和 setter:

void Record::setArrival(Arrival arrival){
    this->arrival = arrival;
}
Arrival Record::getArrival(){
    return this->arrival;
}
Run Code Online (Sandbox Code Playgroud)

getDate() 到达功能:

QDateTime Arrival::getDate(){
    QDateTime qDateTime;

    QDate qDate;
    qDate.setDate(date.getDateYear(), date.getDateMonth(), date.getDateDay());
    qDateTime.setDate(qDate);

    vector<string> timeS = splitTime(time.getTimeFrom());

    QTime qTime;
    qTime.setHMS(stoi(timeS[0]), stoi(timeS[1]), 0);
    qDateTime.setTime(qTime); …
Run Code Online (Sandbox Code Playgroud)

c++ qt qsort qlist

5
推荐指数
2
解决办法
3951
查看次数

SimpleDateFormat仅获取时间

当我尝试仅从时间戳获取时间时,我遇到了问题。

时间戳的一个示例是:

2012-04-19T23:05:00 + 0200

我认为格式是“ yyyy-MM-dd'T'HH:mm:ss.SSSZ”,对吗?并且必须为“ HH:mm”。

我使用以下代码,但不返回任何内容:

public String getTime(String Vertrektijd){
        final SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
        Date dateObj;
        String newDateStr = null;
        try
        {
            dateObj = df.parse(Vertrektijd);
            SimpleDateFormat fd = new SimpleDateFormat("HH:mm");
            newDateStr = fd.format(dateObj);
        }
        catch (Exception e)
        {
          e.printStackTrace();
        }
        return newDateStr;
    }
Run Code Online (Sandbox Code Playgroud)

谢谢您的帮助!

android timestamp date-format simpledateformat

2
推荐指数
1
解决办法
1万
查看次数

标签 统计

android ×1

c++ ×1

date-format ×1

qlist ×1

qsort ×1

qt ×1

simpledateformat ×1

timestamp ×1