本文整理汇总了C++中PythonQtObjectPtr::call方法的典型用法代码示例。如果您正苦于以下问题:C++ PythonQtObjectPtr::call方法的具体用法?C++ PythonQtObjectPtr::call怎么用?C++ PythonQtObjectPtr::call使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PythonQtObjectPtr
的用法示例。
在下文中一共展示了PythonQtObjectPtr::call方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FetchWebdavUrlWithIdentity
bool WebDavInventoryDataModel::FetchWebdavUrlWithIdentity()
{
pythonQtMainModule_.evalScript("import connection\n");
PythonQtObjectPtr httpclient = pythonQtMainModule_.evalScript("connection.HTTPClient()\n", Py_eval_input);
// Some url verification, remove http:// and everything after the port
int index = hostUrl_.indexOf("http://");
if (index != -1)
hostUrl_ = hostUrl_.midRef(index+7).toString();
index = hostUrl_.indexOf("/");
if (index != -1)
hostUrl_ = hostUrl_.midRef(0, index).toString();
// Set up HTTP connection to Taiga WorldServer
httpclient.call("setupConnection", QVariantList() << hostUrl_ << "openid" << identityUrl_);
// Get needed webdav access urls from Taiga WorldServer
QStringList resultList = httpclient.call("requestIdentityAndWebDavURL").toStringList();
// Store results
if (resultList.count() < 1)
return false;
webdavIdentityUrl_ = resultList.value(0);
webdavUrl_ = resultList.value(1);
return true;
}
示例2: data
bool CPythonNode::data(QString gate_name, const CConstDataPointer &data)
{
Q_UNUSED(gate_name);
if(data->getType() == "table") {
// Get the table data structured received.
QSharedPointer<const CTableData> p_table = data.staticCast<const CTableData>();
// Create a table data structure to forward.
QSharedPointer<CTableData> result_table = QSharedPointer<CTableData>(
static_cast<CTableData *>(createData("table")));
QString script_name = getConfig().getParameter("input_script")->value.toString();
// Start a new python context independant of any other.
PythonQtObjectPtr module = PythonQt::self()->createUniqueModule();
// Evaluate the user-supplied python script.
module.evalFile(script_name);
// Call the 'main' function of the user script with the received table
// ... and a table that will contatin the results as arguments.
QVariant result = module.call("main",
QVariantList() << QVariant::fromValue(p_table.data())
<< QVariant::fromValue(result_table.data()));
if(result.toBool()) {
commit("out", result_table);
}
return true;
}
else if(data->getType() == "tcpstreams") {
// The TCP Streams data structure.
QSharedPointer<const CTcpStreamsData> p_flows = data.staticCast<const CTcpStreamsData>();
// Create a table data structure to forward.
QSharedPointer<CTableData> result_table = QSharedPointer<CTableData>(
static_cast<CTableData *>(createData("table")));
QString script_name = getConfig().getParameter("input_script")->value.toString();
// Start a new python context independant of any other.
PythonQtObjectPtr module = PythonQt::self()->createUniqueModule();
// Evaluate the user-supplied python script.
module.evalFile(script_name);
// Call the 'main' function of the user script with the received table
// ... and a table that will contatin the results as arguments.
QVariant result = module.call("main",
QVariantList() << QVariant::fromValue(p_flows.data())
<< QVariant::fromValue(result_table.data()));
// If the python script returned true, commit the results' table.
if(result.toBool()) {
commit("out", result_table);
}
return true;
}
return false;
}
示例3: setDocument
void PyQcsObject::setDocument(int index)
{
QString name = m_qcs->setDocument(index);
PythonQtObjectPtr mainContext = PythonQt::self()->getMainModule();
QString path = name.left(name.lastIndexOf("/"));
mainContext.call("os.chdir", QVariantList() << path );
mainContext.evalScript("print 'cd \"" + path + "\"'");
}
示例4: self
QVariant
lookupAndCall( PyObject* object,
const QStringList& candidateNames,
const QVariantList& args,
const QVariantMap& kwargs )
{
Q_ASSERT( object );
Q_ASSERT( !candidateNames.isEmpty() );
for ( const QString& name : candidateNames )
{
PythonQtObjectPtr callable = PythonQt::self()->lookupCallable( object, name );
if ( callable )
return callable.call( args, kwargs );
}
// If we haven't found a callable with the given names, we force an error:
return PythonQt::self()->call( object, candidateNames.first(), args, kwargs );
}