void Closure::Connect(QObject* sender, const char* signal) { bool success = connect(sender, signal, SLOT(Invoked())); Q_ASSERT(success); success = connect(sender, SIGNAL(destroyed()), SLOT(Cleanup())); Q_ASSERT(success); Q_UNUSED(success); }
ObjectHelper::ObjectHelper( QObject* sender, const char* signal, ClosureBase* closure) : closure_(closure) { connect(sender, signal, SLOT(Invoked())); connect(sender, SIGNAL(destroyed()), SLOT(deleteLater())); }
bool SignalsTest::Run(int argc, char** argv) { dt::Root& root = dt::Root::GetInstance(); root.Initialize(argc, argv); TestComponent component("test"); CallbackClass callback; QObject::connect(&component, SIGNAL(Invoked()), &callback, SLOT(TheCallback())); component.Invoke(); if(!callback.mInvoked) { std::cerr << "Signal callback not received correctly." << std::endl; return false; } root.Deinitialize(); return true; }
QVariant ConsoleCommand::Invoke(const QStringList ¶ms) { QVariant returnValue; // If we have a target QObject, invoke it. if (target) { // Check if we're invoking function with default arguments. QString func = functionName; int numRequiredArgs = FunctionInvoker::NumArgsForFunction(target, functionName); if (params.size() < numRequiredArgs && !functionNameDefaultArgs.isEmpty()) func = functionNameDefaultArgs; QString errorMessage; FunctionInvoker::Invoke(target, func, params, &returnValue, &errorMessage); if (!errorMessage.isEmpty()) LogError("ConsoleCommand::Invoke returned an error: " + errorMessage); } // Also, there may exist a script-registered handler that implements this console command - invoke it. emit Invoked(params); return returnValue; }
void ConsoleCommand::Invoke(const QStringList ¶ms) { emit Invoked(params); }
void Closure::forceInvoke() { Invoked(); }
void TestComponent::Invoke() { emit Invoked(); }