Overview QT study notes (b)

A, QT and JS / the HTML communication interaction 
premise:   advancing the connector QWebFrame javaScriptWindwoObjectCleared signal JS is added to the object itself window object, that is: QwebFrame :: addToJavaScriptWindowObject ( "someObj",
the this );   wherein the JS is someObj QT callable object name, i.e. someobj refer to this object passed in;   secondly, the subject method can be called the JS someobj constant if the slot function. QT execute JS code: QWebFrame :: evaluateJaveScrit method, JS environmental parameter codes; JS return value of the last expression was performed corresponding to the JS. Further QWbeElement element object the function to be performed, to perform JS expression. JS performed QT method: someobj.somefunc, somefunc will function as a groove. Structure: QWebView |   | QWebPage |      | QWebFrame-- (QWebFrames) QWebView for the window class, other classes are data types. QWebPage on behalf of a web page. QWebFrame main frame containing a plurality of sub-frames. QT embedded JS / HTML / CSS improves flexibility, UI interface customization. Two, QT View / model architecture datasets (data) | | (edit data) | | model ---------------- (edit data) ------ | | ( to the data) commissioned | | view ------ (render / to the data) ------ | view / model architecture model of table model (model list), tree model model QT provides: QObject QAbstractListModel QStringListModel QHelpIndexModel QAbstractProxyModel QSortFilterProxyModel QAbstractTableModel QSqlQueryModel QSqlTableModel QSqlRelationalTableModel QAbstractItemModel QDirModel QFileSystemModel QHelpContentModel QProxyModel QStandardItemModel wherein QStandardItemModel as lists, tables, trees generic model, and provides basic functions of realization (binding QStandardItem), when the data amount is large there may be performance problems, ships or other inheritable QAbstractItemModel corresponding model implementation custom models. In addition QT convenience controls, such as QListWidget, QTreeWidget, QTableWidget inherited from the corresponding QXXXView class that provides built-in model implementation; in addition QCombobox. QAbstractProxyModel subclass generally used as a packaging model package sort, filter, etc., to encapsulate the other model, that is, setSourceMode. View / model architecture of entrustment
  QT standard view class, QListView, QTableView, QTreeView, QComboBox as the data provided to display and edit a QStyledItemDelegate. Delegate object can be displayed complete control over the appearance of the view.   
1 . Associated with the data type of editor     to use a specific widget QItemEditorFctory registered as a specific type of one or several editor.   2 . Associated with the data type of commission     for a particular row, column data type to create relevant commission. You can create additional delegate different data classes. Built-general delegate for QStyleItemDelegate. Delegate achieve self-defined columns or rows, in succession QStyleItemDelegate, and implement the corresponding virtual functions as paint or the like, and calls can be used from setItemDeleteForRow setItemDeleteForColumn or delegate definition to replace the built-in delegate; redrawn achieve rewriting paint, If the re-implemented to support editing, is required to achieve createEditor, setEditorData, setModeData the like; Paint draw any method may further comprise the elements as well as a combination of complex controls or controls.   3 . Commission associated with the model     in commission basis related to the data types on the same inheritance achieve QStyleItemDelegate subclass, and determines for content paint according to the desired columns; call setItemDelegate disposed delegate, rather than a column or row delegate; so in createEditor may return to a different editing window object according to a different column or row, with several other similar interfaces need data corresponding to the processing or behavior of the respective column or row.     As compared with the type of data based on the principal of columns or rows, which is more versatile and flexible, while the former delegate all code together complete, direct control of the appearance and the model editing.     Custom delegate is the most common and most convenient control model for the rendering and editing mode, when the implementation is different if they wanted to built QT view to presenting data item or items to customize the appearance of interrelated, we need to use customized views of. View / model architecture of view
  QT is built into the standard view: QListView, QTableView, QTreeView, QComboBox and so on. Of course, these views can be inherited or subclass used to delegate its custom display rendered data model. However, when the data need to be rendered or the way you need to display a custom view implementation in some way to combine two or more of the data.   Create Custom View mode:   
1 . Subclass inherits class or standard view QAbstractItemView implementation class (opposite can be multiplexed), the data items and display items generally is one to one, to draw their own view essentially no (increasing portion can of course also other additional drawing information) instead entrusted to the view, the view may be built custom delegate commission or set by the user to draw these data items.   2 . QWidget subclass and provide their own API and contains setModel interface implementation classes (generally difficult to reuse, and can be implemented associated with a plurality of different display items drawing, may need to implement the necessary integration).   In general, using a custom delegate or use a custom view QAbstractItemView API implementations can not meet the requirements based on the custom view is completely free and flexible.   Usually QStandardItemModel to use, or subclass QStandardItemModel (or QStandardItem) so that data can be serialized and deserialized, if necessary custom model can also be used; the same, using standard built QT view displays the data model is the best manner, or if desired appearance it is preferred to edit data items easiest way is to use a custom delegate, and to delegate standard custom views to display the drawing data item can be used to customize the view presented by way. Three, QT graphics / view window
Typically through a custom QWidget subclass and implements paintEvent and using QPainter achievable draw arbitrary content, corresponding to this custom implementation of widgets easy, but for a large number of individual items, it may affect the interactive performance and graphics item. Graphics
/ QGraphicsView as a center view frame to form the window element as a graphic user interface of other items placed therein. Relative to the view / model framework, the former uses QGraphicsScene (scene pattern) to receive the data item as a model similar, QGraphicsView data to a visual display. Graphic scene contains a graphical items derived from the abstract class QGraphicsItem, including QT built predefined graphic item and custom graphic item or even items may also be a scene. Coordinate system:   logical coordinates of the window;: Scene coordinate system of   the view coordinate system: physical coordinates of the viewport; item in the coordinate system: the center ( 0 , 0 logical coordinates) of the point (upper left corner of the text item is used as a center ); four, QT graphics / view of the scene five, QT animation state machine six other
voice and video   for small files or functions simply use QSound, QMovie;   or advanced powerful Phonon multimedia framework; use QtMutimedia after QT5 module replacement. Multithreading and concurrent rich-text editor

 

Guess you like

Origin www.cnblogs.com/haomiao/p/11647017.html