当前位置:网站首页>QT signal slot summary -connect function incorrect usage
QT signal slot summary -connect function incorrect usage
2022-07-02 09:38:00 【Ignorant dream fireworks】
QT Library qobject.h
connect Function declaration :connect The function is used to establish the connection between the signal and the slot ,QT The library provides three implementations :
static QMetaObject::Connection connect(const QObject *sender, const char *signal,
const QObject *receiver, const char *member, Qt::ConnectionType = Qt::AutoConnection);
static QMetaObject::Connection connect(const QObject *sender, const QMetaMethod &signal,
const QObject *receiver, const QMetaMethod &method,
Qt::ConnectionType type = Qt::AutoConnection);
inline QMetaObject::Connection connect(const QObject *sender, const char *signal,
const char *member, Qt::ConnectionType type = Qt::AutoConnection) const;
class ConnectCamera : public QWidget
{
Q_OBJECT
public:
ConnectCamera(QWidget *parent = Q_NULLPTR);
~ConnectCamera();
public slots:
void onConnectBtnSolt();
void onCancelBtSolt();
void onErrorMess(const QString & _errorMess);
signals:
void signalConnectCamera(const QString& _ip, const QString& _user, const QString& _pass);
private:
Ui::ConnectCamera ui;
};
Use QT The first implementation provided by the Library , To bind signals to slots
Proper use 1:
connect(ui.okButton, SIGNAL(clicked()), this, SLOT(onConnectBtnSolt()));
connect(ui.cancelButton, SIGNAL(clicked()), this, SLOT(onCancelBtSolt()));
Incorrect usage 1:
connect(ui.okButton, SIGNAL(clicked()), this, SLOT(onConnectBtnSolt));
Cause analysis :
usage 1 Called connect Function is actually :
static QMetaObject::Connection connect(const QObject *sender, const char *signal,
const QObject *receiver, const char *member, Qt::ConnectionType = Qt::AutoConnection);
// SLOT The definition of
Q_CORE_EXPORT const char *qFlagLocation(const char *method);
# define SLOT(a) qFlagLocation("1"#a QLOCATION)
qt The signal slot in , The callback function is actually used ,onConnectBtnSolt() Is parsed as a function ,onConnectBtnSolt Format judgment will make mistakes
A very detailed explanation on the Internet ,QT The version may be earlier than 5.9.6
QT QObject::connect Function learning
边栏推荐
- VIM操作命令大全
- 保存视频 opencv::VideoWriter
- Microservice practice | declarative service invocation openfeign practice
- Fragmenttabhost implements the interface of housing loan calculator
- 洞见云原生|微服务及微服务架构浅析
- BugkuCTF-web21(详细解题思路及步骤)
- Read 30 minutes before going to bed every day_ day4_ Files
- MySQL multi column in operation
- Elastic Stack之Beats(Filebeat、Metricbeat)、Kibana、Logstash教程
- Matplotlib swordsman line - first acquaintance with Matplotlib
猜你喜欢
Matplotlib swordsman line - first acquaintance with Matplotlib
YOLO物体识别,生成数据用到的工具
图像识别-数据标注
Difference between redis serialization genericjackson2jsonredisserializer and jackson2jsonredisserializer
分享一篇博客(水一篇博客)
Number structure (C language -- code with comments) -- Chapter 2, linear table (updated version)
QT QLabel样式设置
Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedd
Don't look for it. All the necessary plug-ins for Chrome browser are here
2837xd 代码生成——补充(3)
随机推荐
Chrome浏览器标签管理插件–OneTab
因上努力,果上随缘
QT QLabel样式设置
2837xd 代码生成——StateFlow(3)
JVM指令助记符
Ckeditor 4.10.1 upload pictures to prompt "incorrect server response" problem solution
2837xd 代码生成——StateFlow(4)
2837xd 代码生成——总结篇
AMQ 4043 solution for errors when using IBM MQ remote connection
Difference between redis serialization genericjackson2jsonredisserializer and jackson2jsonredisserializer
互联网API接口幂等设计
Machine learning practice: is Mermaid a love movie or an action movie? KNN announces the answer
Typeerror: X () got multiple values for argument 'y‘
MySQL default transaction isolation level and row lock
Probability is not yet. Look at statistical learning methods -- Chapter 4, naive Bayesian method
FragmentTabHost实现房贷计算器界面
并网逆变器PI控制(并网模式)
Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedd
Bold prediction: it will become the core player of 5g
MySql报错:unblock with mysqladmin flush-hosts