[英]Is a QTreeView::sortByColumn() slot in QTreeView of Qt 5?
In Qt docs http://doc.qt.io/qt-5/model-view-programming.html#model-subclassing-reference , it's said that, If your model is sortable, ie, if it reimplements the QAbstractItemModel::sort()
function, both QTableView
and QTreeView
provide an API that allows you to sort your model data programmatically. 在Qt docs http://doc.qt.io/qt-5/model-view-programming.html#model-subclassing-reference中 ,有人说,如果您的模型是可排序的,即它是否重新实现了
QAbstractItemModel::sort()
函数, QTableView
和QTreeView
提供了一个API,可让您以编程方式对模型数据进行排序。 In addition, you can enable interactive sorting (ie allowing the users to sort the data by clicking the view's headers), by connecting the QHeaderView::sortIndicatorChanged() signal
to the QTableView::sortByColumn() slot
or the QTreeView::sortByColumn() slot
, respectively. 另外,通过将
QHeaderView::sortIndicatorChanged() signal
连接到QTableView::sortByColumn() slot
或QTreeView::sortByColumn() slot
),可以启用交互式排序(即允许用户通过单击视图的标题对数据进行排序)。 QTreeView::sortByColumn() slot
。 However, the QTreeView::sortByColumn()
is not a slot in QTreeView
in Qt 5.4. 但是,
QTreeView::sortByColumn()
在Qt 5.4中的QTreeView
中不是插槽。 Is there any thing wrong?The source code in Src/qtbase/src/widgets/itemviews/qtreeview.h shows that. 有什么问题吗? Src / qtbase / src / widgets / itemviews / qtreeview.h中的源代码显示了这一点。
QTreeView::sortByColumn
wasn't a slot before: http://qt-project.org/doc/qt-4.8-snapshot/qtreeview.html#sortByColumn QTreeView::sortByColumn
之前不是插槽: http QTreeView::sortByColumn
And QTreeView::sortByColumn
isn't a slot now: http://doc.qt.io/qt-5/qtreeview.html#sortByColumn 而且
QTreeView::sortByColumn
现在不再是广告位: http QTreeView::sortByColumn
There is nothing "wrong" with this implementation. 此实现没有任何“错误”。 The behavior of Qt 5 QTreeView will work exactly like a Qt 4 QTreeView with respect to
sortByColumn
. Qt的5 QTreeView则的行为,将工作完全像一个Qt 4 QTreeView则相对于
sortByColumn
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.