zoukankan      html  css  js  c++  java
  • 实现控件不响应鼠标点击事件

    QT中很多控件都有鼠标点击的事件响应,比如QPushButton,QRadioButton。有时候我们想要实现的是:当鼠标点击控件时,不会产生响应事件。其中的一种方法是使用Qt::WA_TransparentForMouseEvents。

    官方对Qt::WA_TransparentForMouseEvents的说明为

    When enabled, this attribute disables the delivery of mouse events to the widget and its children. Mouse events are delivered to other widgets as if the widget and its children were not present in the widget hierarchy; mouse clicks and other events effectively "pass through" them. This attribute is disabled by default.

    大概的意思是当使能Qt::WA_TransparentForMouseEvents时,鼠标事件就不会传送到该控件及子控件,而是会传到其他的不包含该控件的widget上,这样的话其实就是实现了鼠标穿透的功能。

    实现代码

    ui->radioButton->setAttribute(Qt::WA_TransparentForMouseEvents, true);
    使radioButton控件不响应鼠标点击事件。
    原文链接:https://blog.csdn.net/qiufenpeng/article/details/81745266

    坚持成就伟大
  • 相关阅读:
    转: winform间的传值并linklabel动态窗口跳转
    app.config配置
    RSS2.0中文规范
    windows forms 窗口跳转
    C#对DataGridView进行添加、修改、删除数据操作
    小小一颗心
    小记上海一天
    又一个婉约的日子
    七夕节
    我的实习
  • 原文地址:https://www.cnblogs.com/xian-yongchao/p/15395914.html
Copyright © 2011-2022 走看看