The use of mousemoveevent in QT

Source: Internet
Author: User

In Qt to capture the mouse movement events need to rewrite mousemoveevent, but mousemoveevent in order to not consume resources, by default, only the mouse press move to capture. Setmousetracking (TRUE) is required to capture movement when the mouse is not pressed.

Note: If the control you want to respond to a mouse event is contained by a parent control, the control and its parent control or container also need setmousetracking (true); As the standard qlable in my program is promoted to MyLabel by my custom class, in the main interface I first set up a widget1 of container container qwidget, then put some mylable, and now need to be prompted when the mouse moves over the label. The following work needs to be done: First call setmousetracking (true) in the custom class. You need to call Ui.widget1->setmousetracking (TRUE) in the main interface afterwards.


The use of mousemoveevent in QT

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