c++ - QtCreator如何识别正在使用的是哪个override?

标签 c++ qt signals overloading

在 QtCreator 中,当您将鼠标悬停在 Qt 函数上时,它会为您提供上下文帮助,为调用提供所有各种重载的编号。

问题是,在 QObject::connect 的情况下,有 8 个可用的重载,我怎么知道实际使用了哪一个?

我有现有代码,我正在尝试确定正在使用的重载方法,以便我可以清理代码并使用类型来替换:

QObject::connect(this
                        ,&clsQtPushBtn::clicked
                        ,[pobjScriptEng, strCall, strFile, strScript]() {
                            if ( strCall.isEmpty() != true ) {
                                QString strScriptWithCall = static_cast<QString>(strScript)
                                                         + static_cast<QString>(strCall) + "();";
                                pobjScriptEng->evaluate(strScriptWithCall);
                            }
                        });

我想要做的是替换参数,将下面的代码分配给一个临时变量并将其分配为参数:

   [pobjScriptEng, strCall, strFile, strScript]() {
     if ( strCall.isEmpty() != true ) {
       QString strScriptWithCall = static_cast<QString>(strScript)
                                + static_cast<QString>(strCall) + "();";
       pobjScriptEng->evaluate(strScriptWithCall);
     }
   }

这是因为我想在其他连接中重用相同的参数而不必复制源。

最佳答案

连接中有 lambda,所以所有可能的重载方法的选项 7

你可以在参数中使用 ctrl + space 来检查哪个通过得更好

enter image description here

关于c++ - QtCreator如何识别正在使用的是哪个override?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54691126/

相关文章:

c++ - 来自非 qt 线程的信号 qt,QueuedConnection

MySQL:无法在触发器中使用 SIGNAL

android - unw_init_remote 因 UNW_EBADREG 而失败

c++ - 不变问题和隐式 move 构造函数

c++ - 将 qmake 文件转换为 unix makefile

c++ - 数据结构/容器选择

c++ - Qt:如何继承QQuickPath类

c - 为什么信号在 Linux 中依赖于平台?

c++ - 为什么 new int (*)[3] 是错误的?

c++ - 如何在 C++ 中将 CString 转换为 CTime?