当前位置:网站首页>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
边栏推荐
- 洞见云原生|微服务及微服务架构浅析
- 微服务实战|负载均衡组件及源码分析
- Read Day6 30 minutes before going to bed every day_ Day6_ Date_ Calendar_ LocalDate_ TimeStamp_ LocalTime
- MySQL multi column in operation
- 道阻且长,行则将至
- C语言之最小数
- 记录下对游戏主机配置的个人理解与心得
- Beats (filebeat, metricbeat), kibana, logstack tutorial of elastic stack
- Solutions to Chinese garbled code in CMD window
- C语言之到底是不是太胖了
猜你喜欢

TD联合Modelsim进行功能仿真

A detailed explanation takes you to reproduce the statistical learning method again -- Chapter 2, perceptron model

Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedd

How to install PHP in CentOS

hystrix 实现请求合并

Number structure (C language -- code with comments) -- Chapter 2, linear table (updated version)

MySQL事务

Solution to amq4036 error in remote connection to IBM MQ

How to use pyqt5 to make a sensitive word detection tool

Chrome video download Plug-in – video downloader for Chrome
随机推荐
Customize redis connection pool
How to install PHP in CentOS
[go practical basis] how to customize and use a middleware in gin
Typeerror: X () got multiple values for argument 'y‘
Oracle modify database character set
Microservice practice | Eureka registration center and cluster construction
微服务实战|Eureka注册中心及集群搭建
From concept to method, the statistical learning method -- Chapter 3, k-nearest neighbor method
JVM instruction mnemonic
Don't look for it. All the necessary plug-ins for Chrome browser are here
别找了,Chrome浏览器必装插件都在这了
记录一下初次使用Xray的有趣过程
Oracle modifies tablespace names and data files
每天睡前30分钟阅读Day6_Day6_Date_Calendar_LocalDate_TimeStamp_LocalTime
Solution to amq4036 error in remote connection to IBM MQ
JDBC review
攻防世界-Web进阶区-unserialize3
web安全与防御
zk配置中心---Config Toolkit配置与使用
c语言编程题