The QTableView class provides a default model/view implementation of a table view.
QTableView 提供一个表视图默认的 模型/视图 的实现。
A QTableView implements a table view that displays items from a model.
QTableView 实现了显示 model 中数据项的表视图。
This class is used to provide standard tables that were previously provided by the QTable class,
but using the more flexible approach provided by Qt's model/view architecture.
此类用于提供标准表,该表示此前通过QTable类提供的,但是Qt 的 model/view 体系结构提供了更加灵活的方式。
The QTableView class is one of the Model/View Classes and is part of Qt's model/view framework.
QTableView 是Model/View 类中的一种,是Qt Model/View 框架的一部分。
QTableView implements the interfaces defined by the QAbstractItemView class
to allow it to display data provided by models derived from the QAbstractItemModel class.
QTableView通过QAbstractItemView定义,实现允许显示models提供的数据接口,该models衍生自QAbstractItemModel类。
---------------------------------------------------------------------------------------
Navigation 操纵
You can navigate the cells in the table by clicking on a cell with the mouse, or by using the arrow keys.
可以通过鼠标点击表中的 单元格 进行操纵,或者使用“箭头按键”。
Because QTableView enables tabKeyNavigation by default, you can also hit Tab and Backtab to move from cell to cell.
由于QTableView默认使能tabKeyNavigation,也可以敲击Tab键和回退Tab键,从一个单元格移到下一个单元格。
---------------------------------------------------------------------------------------
void QTableView::setModel(QAbstractItemModel * model) [virtual] //Reimplemented from QAbstractItemView::setModel().
void QAbstractItemView::setModel(QAbstractItemModel * model) [virtual]
Sets the model for the view to present.
为视图的显示设置model。
This function will create and set a new selection model, replacing any model that was previously set with setSelectionModel().
该函数将创建并设置一个新的选择模块,取替预先任何一个通过setSelectionModel 设置的模块。
However, the old selection model will not be deleted as it may be shared between several views.
然而,先前的选择模块并不会被删除,因为它可能在几个视图之间是共享关系。
We recommend that you delete the old selection model if it is no longer required.
我们推荐删除掉不再被请求的选择模块。
This is done with the following code:
QItemSelectionModel *m = view->selectionModel();
view->setModel(new model);
delete m;
If both the old model and the old selection model do not have parents, or if their parents are long-lived objects,
it may be preferable to call their deleteLater() functions to explicitly delete them.
如果先前的模块和先前的选择模块没有parents,或者它们的parents是长生命期的类,
更好的方式是调用它们的deleteLater()函数显式的删除掉它们。
The view does not take ownership of the model unless it is the model's parent object
because the model may be shared between many different views.
视图不再用于该model的所有权,除非它是该model的parent类,因为该模型可能在很多不同的视图之间共享。
--------------------------------------------------------
QAbstractItemModel * QAbstractItemView::model() const
Returns the model that this view is presenting.
返回视图正在显示中的model。
QTableView 提供一个表视图默认的 模型/视图 的实现。
A QTableView implements a table view that displays items from a model.
QTableView 实现了显示 model 中数据项的表视图。
This class is used to provide standard tables that were previously provided by the QTable class,
but using the more flexible approach provided by Qt's model/view architecture.
此类用于提供标准表,该表示此前通过QTable类提供的,但是Qt 的 model/view 体系结构提供了更加灵活的方式。
The QTableView class is one of the Model/View Classes and is part of Qt's model/view framework.
QTableView 是Model/View 类中的一种,是Qt Model/View 框架的一部分。
QTableView implements the interfaces defined by the QAbstractItemView class
to allow it to display data provided by models derived from the QAbstractItemModel class.
QTableView通过QAbstractItemView定义,实现允许显示models提供的数据接口,该models衍生自QAbstractItemModel类。
---------------------------------------------------------------------------------------
Navigation 操纵
You can navigate the cells in the table by clicking on a cell with the mouse, or by using the arrow keys.
可以通过鼠标点击表中的 单元格 进行操纵,或者使用“箭头按键”。
Because QTableView enables tabKeyNavigation by default, you can also hit Tab and Backtab to move from cell to cell.
由于QTableView默认使能tabKeyNavigation,也可以敲击Tab键和回退Tab键,从一个单元格移到下一个单元格。
---------------------------------------------------------------------------------------
void QTableView::setModel(QAbstractItemModel * model) [virtual] //Reimplemented from QAbstractItemView::setModel().
void QAbstractItemView::setModel(QAbstractItemModel * model) [virtual]
Sets the model for the view to present.
为视图的显示设置model。
This function will create and set a new selection model, replacing any model that was previously set with setSelectionModel().
该函数将创建并设置一个新的选择模块,取替预先任何一个通过setSelectionModel 设置的模块。
However, the old selection model will not be deleted as it may be shared between several views.
然而,先前的选择模块并不会被删除,因为它可能在几个视图之间是共享关系。
We recommend that you delete the old selection model if it is no longer required.
我们推荐删除掉不再被请求的选择模块。
This is done with the following code:
QItemSelectionModel *m = view->selectionModel();
view->setModel(new model);
delete m;
If both the old model and the old selection model do not have parents, or if their parents are long-lived objects,
it may be preferable to call their deleteLater() functions to explicitly delete them.
如果先前的模块和先前的选择模块没有parents,或者它们的parents是长生命期的类,
更好的方式是调用它们的deleteLater()函数显式的删除掉它们。
The view does not take ownership of the model unless it is the model's parent object
because the model may be shared between many different views.
视图不再用于该model的所有权,除非它是该model的parent类,因为该模型可能在很多不同的视图之间共享。
--------------------------------------------------------
QAbstractItemModel * QAbstractItemView::model() const
Returns the model that this view is presenting.
返回视图正在显示中的model。