六十一、QT之信号与lambda槽函数

一、函数原型

inline QMetaObject::Connection QObject::connect(const QObject *asender, const char *asignal, const char *amember, Qt::ConnectionType atype)

二、应用

//直接调用 lambda,信号必须用指针的形式写
connect(act, &QAction::triggered, [=](){
    if (itemId.isEmpty()) {
        App::showMessageBoxError(tr("错误"), tr("请先设置单位信息,再设置席位!"));
        return;
    }
    DialogSeats *dialogSeats = new DialogSeats(itemId, this);
    int result = dialogSeats->exec();
    if (result == QDialog::Accepted) {
        refreshTree();
    }
    delete dialogSeats;
});
menu->addAction(act);
menu->exec(this->cursor().pos());
}

备注:直接调用 lambda,信号必须用指针的形式写!!!

你可能感兴趣的:(QT)