PyQt5 study notes,

Source: Internet
Author: User

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 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.