小编use*_*931的帖子

如何在QList中使用qSort和自定义类型?

我在排序QList包含以下内容的实例时遇到问题struct:

class modelHeuristic
{

    typedef struct {

         QString c;
         QString t;
         double value;
     }Saving;

public:

QList<Saving> list_saving;

#include "klarkeright.h"

klarkeRight::klarkeRight()
{


}
void klarkeRight::Algoritmo_Asimetrico(modelHeuristic *model)
{

    qSort(model->list_saving.begin(), model->list_saving.end());

}
Run Code Online (Sandbox Code Playgroud)

错误:二进制表达式的无效操作数('const modelHeuristic :: Saving'和'const modelHeuristic :: Saving')return(t1 <t2);

c++ sorting qt qlist qtcore

3
推荐指数
1
解决办法
7313
查看次数

标签 统计

c++ ×1

qlist ×1

qt ×1

qtcore ×1

sorting ×1