PyQt5 study notes,
SetMouseTracking
Bool mouseTracking
This property stores the Window widget tracking whether the mouse has taken effect.
If the mouse tracking is invalid (default), This widget receives the mouse movement event only when at least one mouse button is pressed when the mouse is moved.
If the mouse tracking takes effect and no buttons are pressed, the widget also receives the mouse movement event.
You can also refer to mouseMoveEvent () and QApplication: setGlobalMouseTracking ().
SetMouseTracking () is used to set the attribute value and hasMouseTracking () is used to obtain the attribute value.
After this function is called, if you want to make the mouseMoveEvent effective, that is, moving the mouse in the area will trigger, rather than triggering the mouse when pressing the button, note that it can only be QWidget, if it is QMainwindow, invalid.
Zookeeper --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Difference between QTableWidget and QTableView
QTableWidget is a space commonly used in QT programs to display data tables. It is similar to the DataGrid in VC and C. QTableWidget inherits from QTableView. QSqlTableModel can be bound to QTableView, but cannot be bound to QTableWidget.
QTableWidget is a subclass of QTableView. The main difference is that QTableView can use a custom data model to display content (that is, you must bind the data source through setModel first ), QTableWidget can only use the standard data model, and its cell data is implemented by the QTableWidgetItem object (that is, you can fill in the information in cells one by one without the data source ). This is mainly reflected in the fact that the QTableView class has the setModel member function. In the QTableWidget class, the member function becomes private. QTableWidget is inseparable from QTableWidgetItem. QTableWidgetItem is used to represent a cell in the table. The entire table needs to be constructed with cells one by one.
Differences
Differences |
QTableView |
QTableWidget |
Inheritance relationship |
|
QTableWidget inherited from QTableView |
Use the data model setModel |
You can use setModel to set the data model. |
SetModel is a private function. You cannot use this function to set the data model. |
Show check box setCheckState |
No function implementation check box |
SetCheckState (Qt: Checked) in the QTableWidgetItem class; check boxes can be set. |
Bind with QSqlTableModel |
QTableView can be bound to QSqlTableModel |
QtableWidget cannot be bound to QSqlTableModel |
Zookeeper --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------