c – 如何使用Qt库(可能是qSort())排序QList?
发布时间:2020-12-16 05:32:14 所属栏目:百科 来源:网络整理
导读:class MyClass { public: int a; bool operator(const MyClass other) const { return aother.a; } ....};....QListMyClass* list; 解决方法 制作自己的比较器,这将使用指针,然后使用qSort: http://qt-project.org/doc/qt-5.1/qtcore/qtalgorithms.html#qSo
class MyClass { public: int a; bool operator<(const MyClass other) const { return a<other.a; } .... }; .... QList<MyClass*> list; 解决方法
制作自己的比较器,这将使用指针,然后使用qSort:
http://qt-project.org/doc/qt-5.1/qtcore/qtalgorithms.html#qSort-3
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |