Qt中信号和槽执行的顺序执行特性

更新时间:2023-06-14 04:19:51 阅读: 评论:0

Qt中信号和槽执⾏的顺序执⾏特性
1. 因为signal-slot本⾝是⼀个顺序执⾏的过程,只有执⾏完slot之后,才会执⾏emit的下⼀条语句。
2. 如果使⽤队列连接⽅式,则在emit信号后,先执⾏emit语句后⾯的代码,执⾏完成后再执⾏对应的槽函数;
思想政治教育研究3. 代码实例:王旁
#include "widget.h"
#include "ui_widget.h"
#include <QDebug>
Widget::Widget(QWidget *parent) :
QWidget(parent),
心理健康教育专业ui(new Ui::Widget)
{
ui->tupUi(this);
connect(ui->pushButton, SIGNAL(clicked()), this, SLOT(slot1())/*, Qt::QueuedConnection*/);
connect(this, SIGNAL(signal1()), this ,SLOT(slot2()));//info1
connect(this, SIGNAL(signal1()), this ,SLOT(slot2()), Qt::QueuedConnection);//info2
/*
*
* info1:emit信号发出后,先执⾏槽函数,再执⾏emit后⾯的语句;
* info2:emit信号发出后,使⽤队列连接信号和槽,这个时候,先执⾏emit后⾯的语句,在执⾏槽函数
* info:[
emit signal1()
enter slot2自评报告
start to enter slot2()s
];
info2:[冰箱保鲜温度
emit signal1()
start to enter slot2()s
enter slot2
]
红烧羊肉汤*/
}
Widget::~Widget()
{
delete ui;
}
void Widget::slot1()
{
烟花散
qInfo() << "emit signal1()";
emit signal1();
qInfo() << "start to enter slot2()s";
}
void Widget::slot2()
暑假英语怎么说{
qInfo() << "enter slot2";
}

本文发布于:2023-06-14 04:19:51,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/82/949837.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:教育   代码   研究   顺序   信号   温度   对应   自评
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图