当前位置:网站首页>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
边栏推荐
- JDBC review
- 每天睡觉前30分钟阅读_day3_Files
- Required request body is missing: (cross domain problem)
- Solution to amq4036 error in remote connection to IBM MQ
- QT QLabel样式设置
- What are the waiting methods of selenium
- Ckeditor 4.10.1 upload pictures to prompt "incorrect server response" problem solution
- C语言之到底是不是太胖了
- 一次聊天勾起的回忆
- Learn combinelatest through a practical example
猜你喜欢

Operation and application of stack and queue

How to use PHP spoole to implement millisecond scheduled tasks

Matplotlib swordsman - a stylist who can draw without tools and code

破茧|一文说透什么是真正的云原生

Solution to amq4036 error in remote connection to IBM MQ

Chrome video download Plug-in – video downloader for Chrome

图像识别-数据采集

Bold prediction: it will become the core player of 5g

Web security and defense

洞见云原生|微服务及微服务架构浅析
随机推荐
[go practical basis] how to customize and use a middleware in gin
TD联合Modelsim进行功能仿真
图像识别-数据增广
Typora installation package sharing
idea查看字节码配置
Microservice practice | fuse hytrix initial experience
洞见云原生|微服务及微服务架构浅析
Double non undergraduate students enter the factory, while I am still quietly climbing trees at the bottom (Part 1)
Chrome user script manager tempermonkey monkey
Read 30 minutes before going to bed every day_ day4_ Files
What are the waiting methods of selenium
How to use PHP spoole to implement millisecond scheduled tasks
C语言之到底是不是太胖了
一次聊天勾起的回忆
tinyxml2 读取和修改文件
上班第一天的报错(Nessus安装winpcap报错)
Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedd
ZK configuration center -- configuration and use of config Toolkit
Alibaba /热门json解析开源项目 fastjson2
Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedd