sr0tzo
V2EX  ›  Qt

Qt 槽只能触发一次,后续 emit 再无法执行槽函数

  •  
  •   sr0tzo · Jul 11, 2020 · 5244 views
    This topic created in 2134 days ago, the information mentioned may be changed or developed.

    void LeftPanelWidget::SearchDateOfDay(const QString &id, const QDate date) { QTime time = QTime(0, 0, 0); QDateTime datetime = QDateTime(date, time); int timestamp = datetime.toTime_t();

    QString channelId = id;
    emit sglQueryTimeline(channelId, timestamp);
    qDebug() << "hahahaha ";
    

    }

    connect(this, &LeftPanelWidget::sglQueryTimeline, [this](QString &id, int ts)
    {
                qDebug() << "query timeline "  << id << "  " << ts;
    });
    

    如上面代码所示,我通过一个控件调用 SearchDateOfDay,单步跟下来确认每次都会 emit,但是槽只在第一次执行了,后面再也不能触发,请哪位大神指点一下问题可能出在哪里?

    3 replies    2020-07-12 16:21:07 +08:00
    imn1
        1
    imn1  
       Jul 11, 2020
    不懂 C++,只玩 pyqt
    你这是什么控件,日历?拖动条?
    多次改变的数据,理论上触发事件应该是 valueChanged,没看到这个
    whi147
        2
    whi147  
       Jul 12, 2020 via iPhone
    一般来说是函数的生命周期结束,被自动回收,你下面这个信号槽链接是否放在构造函数这里
    acainiao
        3
    acainiao  
       Jul 12, 2020 via iPhone
    你们都用 qt 做什么呀? qt 现在不是要收费了?
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2568 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 00:37 · PVG 08:37 · LAX 17:37 · JFK 20:37
    ♥ Do have faith in what you're doing.