zoukankan      html  css  js  c++  java
  • Qt

    转载自:https://blog.csdn.net/liukang325

    加:在main函数中写一个定时器,并启动

    1 QTimer timer;
    2 QObject::connect(&timer, &QTimer::timeout, [&]() {
    3     qDebug() << "Time COOKOO *** write: " << QDateTime::currentDateTime().toString("ss.zzz");   //秒.毫秒
    4 });
    5 timer.start(500);

    1、最基本的,4个参数

    1 //阻塞
    2 QEventLoop loop;
    3 QObject::connect(this, SIGNAL(getRtmpCodeFinished()), &loop, SLOT(quit()));
    4 loop.exec();
    1 QPointer<QAction> sysTrayReplayBuffer;
    2 ...
    3 connect(sysTrayReplayBuffer.data(), &QAction::triggered, this, &HBasic::ReplayBufferClicked);

    2、lamda表达式

    注:

    [a,&b] a变量以值的方式呗捕获,b以引用的方式被捕获;
    [this] 以值的方式捕获 this 指针;
    [&] 以引用的方式捕获所有的外部自动变量(包括this);
    [=] 以值的方式捕获所有的外部自动变量(包括this);
    [] 不捕获外部的任何变量。

    1 HLiveSettings liveSetting(this);
    2 auto getRtmpCodeSlots = [&](QString rtmpStr) {
    3     QDBG << rtmpStr;
    4     ...
    5 };
    6 connect(&liveSetting, &HLiveSettings::getRtmpCode, getRtmpCodeSlots);
    1 auto clickedSlots = [this]() {
    2     ...
    3 };
    4 connect(ui->pushbutton, &QPushButton::clicked, clickedSlots);
    1 m_downLoadManagerForImage = new DownLoadManager(this);
    2 connect(m_downLoadManagerForImage, &DownLoadManager::FileDownloadFinished, [=]()
    3 {
    4     QDBG << "FileDownloadFinished!";
    5     addPendantSource("test");
    6 });
    博客园文作者:Citrusliu 博文地址:https://www.cnblogs.com/citrus
  • 相关阅读:
    [USACO11JAN]Roads and Planes G【缩点+Dij+拓补排序】
    Cheatsheet: 2015 05.01 ~ 05.31
    Cheatsheet: 2015 04.01 ~ 04.30
    Cheatsheet: 2015 03.01 ~ 03.31
    Cheatsheet: 2015.02.01 ~ 02.28
    Cheatsheet: 2015 01.01~ 01.31
    Cheatsheet: 2014 12.01 ~ 12.31
    Cheatsheet: 2014 11.01 ~ 11.30
    Cheatsheet: 2014 10.01 ~ 10.30
    Cheatsheet: 2014 09.01 ~ 09.30
  • 原文地址:https://www.cnblogs.com/citrus/p/13947796.html
Copyright © 2011-2022 走看看