Application QTableView model view (with video presentation)

     QTableView implement a table view showing the terms in the model. This class provides a standard table previously provided by QTABLE class, but use the QT Meave / VIEW architecture provides a more flexible approach. QTableView class is one model / view class, Qt is part of the model / view of the frame. QTableView achieve qabstractemview interface class definition, to allow it to display data derived from the class model qabstractemmodel provided.

     Navigation may be a cell of the table by clicking with the mouse or using the arrow keys cell. Because QTableView tabKeyNavigation enabled by default, so you can also click and Backtab Tab key to move between cells.

The core idea of ​​the model-view design pattern

That the model (data) with a view (display) phase separation

Foreign models only need to provide a standard interface to access data, how the data is displayed without the need

You view only need to customize the display of data without the need to store data how to organize

When the data is changed, the view will be signaled

When a user interacts with the view, the information sent through the signal interaction model

role role data

     When the value is not the same role, in view of the display will be different

     For the role roles, common values ​​are:

Qt :: DisplayRole 0 is displayed in text data (QString)

Qt :: DecorationRole 1 data as icons to decorate (QIcon, QPixmap)

Qt :: EditRole 2 editable display data (QString)

Qt :: ToolTipRole 3 displayed as a tooltip (QString)

Qt :: StatusTipRole 4 data (QString) as shown in the status bar

Qt :: WhatsThisRole 5 bar displays help information as data (QString)

Qt :: FontRole 6 set the font (QFont)

Qt :: TextAlignmentRole 7 model data set text alignment (Qt :: AlignmentFlag)

Qt :: background color model data set BackgroundRole 8 (QBrush)

Qt :: ForegroundRole 9 model data set the foreground color, such as fonts (QBrush)

Source

Public concern specific number to view the video and get the source code

attention

Micro-channel public number search " Qt_io_ " or " Qt Developer Center " to learn more about the development of knowledge ..

I - jxd

Published 43 original articles · won praise 0 · Views 2997

Guess you like

Origin blog.csdn.net/automoblie0/article/details/103209527