上一页 1 ··· 103 104 105 106 107 108 109 110 111 ··· 164 下一页
摘要: 1、发送事件由以下两个函数完成 static void QCoreApplication::postEvent (QObject* receiver, QEvent* event,int priority=Qt::NormalEventPriority); static bool QCoreAppl 阅读全文
posted @ 2020-09-25 20:16 天子骄龙 阅读(794) 评论(0) 推荐(0)
摘要: 需要 #include<QKeyEvent> 常用操作 win.h #ifndef WIN_H #define WIN_H #include <QWidget> #include <QDebug> #include<QKeyEvent> //键盘模块 class Win : public QWidg 阅读全文
posted @ 2020-09-25 13:59 天子骄龙 阅读(1572) 评论(0) 推荐(0)
摘要: 常用操作 判断鼠标按下了哪个键 void Win::mousePressEvent(QMouseEvent *e) { if(e->button() == Qt::LeftButton) //如果鼠标按下的键是左键 //e->button() 返回鼠标当时按下的键--触发事件的键 { qDebug( 阅读全文
posted @ 2020-09-24 09:15 天子骄龙 阅读(1163) 评论(0) 推荐(0)
摘要: 1、事件过滤器用于拦截传递到目标对象的事件,这样可以实现监视目标对象事件的作用 2、Qt 实现事件过滤器的步骤如下: ①、Qt 调用void QObject::installEventFilter (QObject* filterObj),给filterObj 对象设置安装(或注册)事件过滤器,fi 阅读全文
posted @ 2020-09-22 21:14 天子骄龙 阅读(1105) 评论(0) 推荐(0)
摘要: enent事件是通过返回true或false,来决定是否传递事件,不能通过接受accept()或忽略ignore() c.h文件 #ifndef C_H #define C_H #include <QPushButton> #include <QEvent> #include <QDebug> cl 阅读全文
posted @ 2020-09-22 09:34 天子骄龙 阅读(755) 评论(0) 推荐(0)
摘要: 1、事件可以被接受或忽略,被接受的事件不会再传递给其他对象,被忽略的事件会被传递给其他对象处理,或者该事件被丢弃(即没有对象处理该事件) 2、使用 QEvent::accept()函数表示接受一个事件,使用 QEvent::ignore()函数表示忽略一个事件。也就是说若调用 accept(),则事 阅读全文
posted @ 2020-09-21 19:51 天子骄龙 阅读(1277) 评论(0) 推荐(0)
摘要: cpp文件 #include "win.h" #include "ui_win.h" Win::Win(QWidget *parent) : QWidget(parent) , ui(new Ui::Win) { ui->setupUi(this); } Win::~Win() { delete u 阅读全文
posted @ 2020-09-21 09:47 天子骄龙 阅读(292) 评论(0) 推荐(0)
摘要: 事件详谈 事件处理的方式 事件的接受和忽略 event事件的传递 鼠标事件 键盘事件 事件过滤器 自定义事件与事件的发送 event(QEvent *e) 全部事件 事件类型: e->type()==QEvent::KeyPress 键盘按下类型 e->type() == QEvent::Mouse 阅读全文
posted @ 2020-09-21 05:10 天子骄龙 阅读(193) 评论(0) 推荐(0)
摘要: cpp文件 #include "win.h" #include "ui_win.h" Win::Win(QWidget *parent) : QDialog(parent) , ui(new Ui::Win) { ui->setupUi(this); QLabel* label=new QLabel 阅读全文
posted @ 2020-09-19 20:45 天子骄龙 阅读(247) 评论(0) 推荐(0)
摘要: 需要 #include<QVariant> QVariant 类用于封装数据成员的类型及取值等信息,该类类似于 C++共用体 union,一个QVariant 对象,一次只能保存一个单一类型的值。该类封装了 Qt 中常用的类型,对于QVariant 不支持的类型 ( 比如用户自定义类型 ) ,则需要 阅读全文
posted @ 2020-09-19 11:35 天子骄龙 阅读(432) 评论(0) 推荐(0)
上一页 1 ··· 103 104 105 106 107 108 109 110 111 ··· 164 下一页