• qt信号和槽


    类定义时:

    class A {
    
    Q_SIGNALS:
    void syncinitApp(NQIntent *pIntent );
    
    private Q_SLOTS:
    void onSyncinitApp(NQIntent *pIntent );
    
    }

    可在构造函数中进行:

    connect(this, SIGNAL(syncinitApp(NQIntent *)), this, SLOT(onSyncinitApp(NQIntent *)));

    可在析构函数中进行:

    disconnect(this, SIGNAL(syncinitApp(NQIntent *)), this, SLOT(onSyncinitApp(NQIntent *)));

    可在需要跳转处:

    emit syncinitApp(pNQIntent);

    其实还有第五个参数:

    connect(Sender,SIGNAL(signal),Receiver,SLOT(slot),Qt::DirectConnection);

    第五个参数代表槽函数在哪个线程中执行 : (队列连接 = 异步)
    1)自动连接(AutoConnection),默认的连接方式,如果信号与槽,也就是发送者与接受者在同一线程,等同于直接连接;如果发送者与接受者处在不同线程,等同于队列连接。 
    2)直接连接(DirectConnection),当信号发射时,槽函数立即直接调用。无论槽函数所属对象在哪个线程,槽函数总在发送者所在线程执行,即槽函数和信号发送者在同一线程 
    3)队列连接(QueuedConnection),当控制权回到接受者所在线程的事件循环时,槽函数被调用。槽函数在接受者所在线程执行,即槽函数与信号接受者在同一线程

  • 相关阅读:
    c++string字符存取 安静点
    c++ string赋值操作 安静点
    c++ string字符串比较 安静点
    c++string子串 安静点
    c++vector容器 安静点
    c++string容器 构造函数 安静点
    c++ string查找和替换 安静点
    函数柯里化
    419测试神经网络计算过程
    linux 查看文件行号
  • 原文地址:https://www.cnblogs.com/mayfly-xlc/p/9356001.html
Copyright © 2020-2023  润新知