zoukankan      html  css  js  c++  java
  • 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),当控制权回到接受者所在线程的事件循环时,槽函数被调用。槽函数在接受者所在线程执行,即槽函数与信号接受者在同一线程

  • 相关阅读:
    HDU 2544 最短路
    HDU 3367 Pseudoforest
    USACO 2001 OPEN
    HDU 3371 Connect the Cities
    HDU 1301 Jungle Roads
    HDU 1879 继续畅通工程
    HDU 1233 还是畅通工程
    HDU 1162 Eddy's picture
    HDU 5745 La Vie en rose
    HDU 5744 Keep On Movin
  • 原文地址:https://www.cnblogs.com/mayfly-xlc/p/9356001.html
Copyright © 2011-2022 走看看