当前位置: 首页>>代码示例>>C++>>正文


C++ PythonQtObjectPtr类代码示例

本文整理汇总了C++中PythonQtObjectPtr的典型用法代码示例。如果您正苦于以下问题:C++ PythonQtObjectPtr类的具体用法?C++ PythonQtObjectPtr怎么用?C++ PythonQtObjectPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了PythonQtObjectPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: csoundGetChannelDatasize

QString PyQcsObject::getCsStringChannel(QString channel, int index)
{
	CsoundEngine *e = m_qcs->getEngine(index);

	if (e != NULL) {
		CSOUND *cs = e->getCsound();

		if (cs != NULL) {
#ifdef CSOUND6
			int maxlen = csoundGetChannelDatasize(cs, channel.toLocal8Bit());
#else
			int maxlen = csoundGetStrVarMaxLen(cs);
#endif
			char *value = new char[maxlen];
			if ( !( csoundGetChannelPtr(cs,(MYFLT **) &value,channel.toLocal8Bit(),
										CSOUND_STRING_CHANNEL | CSOUND_OUTPUT_CHANNEL))) {
				return QString(value);
			}
		}
	}
	QString message="Could not read from channel "+channel;
	PythonQtObjectPtr mainContext = PythonQt::self()->getMainModule();
	mainContext.evalScript("print \'"+message+"\'");
	return QString();//m_qcs->getCsChannel(channel, index);

}
开发者ID:Ali-I,项目名称:CsoundQt,代码行数:26,代码来源:pyqcsobject.cpp

示例2: main

int main( int argc, char **argv )
{
  QApplication qapp(argc, argv);

  PythonQt::init(PythonQt::IgnoreSiteModule | PythonQt::RedirectStdOut);
  PythonQt_QtAll::init();

  PythonQtObjectPtr  mainContext = PythonQt::self()->getMainModule();

  bool showConsole = false;
  QStringList files;
  for (int i = 1; i < argc; i++) {
    QString arg = argv[i];
    QString argLower = arg.toLower();
    if (argLower == "-console" || argLower == "-c") {
      showConsole = true;
    } else {
      QString file = arg;
      QFileInfo info(file);
      if (info.exists()) {
        files << info.absoluteFilePath();
        // add the file's absolute path for local importing
        PythonQt::self()->addSysPath(info.absolutePath());
      } else {
        QMessageBox::warning(NULL, "PyLauncher", QString("File does not exist: %1").arg(file));
      }
    }
  }
  PythonQtScriptingConsole console(NULL, mainContext);

  Q_FOREACH(QString file, files) {
    mainContext.evalFile(file);
  }
开发者ID:abletterer,项目名称:CGoGN-1,代码行数:33,代码来源:main.cpp

示例3: PythonQtTestSlotCallingHelper

void PythonQtTestSlotCalling::initTestCase()
{
  _helper = new PythonQtTestSlotCallingHelper(this);
  PythonQtObjectPtr main = PythonQt::self()->getMainModule();
  main.evalScript("import PythonQt");
  PythonQt::self()->addObject(main, "obj", _helper);
}
开发者ID:dbrnz,项目名称:PythonQtCopy,代码行数:7,代码来源:PythonQtTests.cpp

示例4: updateGeometry

//----------------------------------------------------------------------------
void DolfinGui::updateGeometry(Geometry *geometry)
{
    // Use python script to obtain values in QLineEdit boxes
    PythonQt::init();
    PythonQtObjectPtr mainModule = PythonQt::self()->getMainModule();
    mainModule.addObject("infoBox", geometry->getInfoBox());
    double *points = new double[geometry->getPointCount()];
    double *radius = new double[geometry->getRadiusCount()];

    std::cout << "Points: " << std::endl;
    for (int i=0; i < geometry->getPointCount(); ++i){
        points[i] = mainModule.evalScript(QString("eval(infoBox.pointEdit%1.text)").arg(i),
                Py_eval_input).toDouble();
        std::cout << i << ": " << points[i] << std::endl;
    }

    if (geometry->getRadiusCount() > 0){
        for (int i=0; i < geometry->getRadiusCount(); ++i){
            radius[i] = mainModule.evalScript(QString("eval(infoBox.radiusEdit%1.text)").arg(i),
                                              Py_eval_input).toDouble();
        }
    }

    geometry->setPoints(points);
    geometry->setRadius(radius);
    geometry->setGeometryPointer(generateGeometry(geometry));

    std::cout << "Point count: " << geometry->getPointCount() << std::endl;
    plotGeometry();
}
开发者ID:nkylstad,项目名称:sommerjobb,代码行数:31,代码来源:DolfinGui.cpp

示例5: csoundGetControlChannelHints

void PyQcsObject::setCsChannel(QString channel, double value, int index)
{
	CsoundEngine *e = m_qcs->getEngine(index);
	MYFLT *p;
	if (e != NULL) {
		CSOUND *cs = e->getCsound();
#ifndef CSOUND6
        if (cs != NULL && !(csoundGetChannelPtr(cs, &p, channel.toLocal8Bit(), CSOUND_CONTROL_CHANNEL | CSOUND_INPUT_CHANNEL))) {
            *p = (MYFLT) value;
            return;
        }
#else
        if (cs) {
            controlChannelHints_t hints;  // this does not work with csound5
			int ret = csoundGetControlChannelHints(cs, channel.toLocal8Bit(), &hints);
			if (ret == 0) {
				csoundSetControlChannel(cs, channel.toLocal8Bit(), (MYFLT) value);
				return;
			}
		}
#endif
    }

	QString message="Channel '" + channel + "' does not exist or is not exposed with chn_k.";
	PythonQtObjectPtr mainContext = PythonQt::self()->getMainModule();
	mainContext.evalScript("print \'"+message+"\'");
}
开发者ID:Ali-I,项目名称:CsoundQt,代码行数:27,代码来源:pyqcsobject.cpp

示例6: 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;
}
开发者ID:Belsepubi,项目名称:naali,代码行数:26,代码来源:WebdavInventoryDataModel.cpp

示例7: 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 + "\"'");
}
开发者ID:Ali-I,项目名称:CsoundQt,代码行数:8,代码来源:pyqcsobject.cpp

示例8: testDynamicProperties

void PythonQtTestApi::testDynamicProperties()
{
  PythonQtObjectPtr main = PythonQt::self()->getMainModule();

  // this fails and should fail, but how could that be tested?
  // main.evalScript("obj.testProp = 1");
  
  // create a new dynamic property
  main.evalScript("obj.setProperty('testProp','testValue')");

  // read the property
  QVERIFY(QString("testValue") == main.getVariable("obj.testProp").toString());
  // modify and read again
  main.evalScript("obj.testProp = 12");
  QVERIFY(12 == main.getVariable("obj.testProp").toInt());

  // check if dynamic property is in dict
  QVERIFY(12 == main.evalScript("obj.__dict__['testProp']", Py_eval_input).toInt());

  // check if dynamic property is in introspection
  QStringList l = PythonQt::self()->introspection(PythonQt::self()->getMainModule(), "obj", PythonQt::Anything);
  QVERIFY(l.contains("testProp"));
  
  // check with None, previous value expected
  main.evalScript("obj.testProp = None");
  QVERIFY(12 == main.getVariable("obj.testProp").toInt());

  // remove the dynamic property
  main.evalScript("obj.setProperty('testProp', None)");

  // check if dynamic property is really gone
  QStringList l2 = PythonQt::self()->introspection(PythonQt::self()->getMainModule(), "obj", PythonQt::Anything);
  QVERIFY(!l2.contains("testProp"));
  
}
开发者ID:dbrnz,项目名称:PythonQtCopy,代码行数:35,代码来源:PythonQtTests.cpp

示例9: testProperties

void PythonQtTestApi::testProperties()
{
  PythonQtObjectPtr main = PythonQt::self()->getMainModule();
  // check for name alias (for backward comp to Qt3)
  main.evalScript("obj.name = 'hello'");
  QVERIFY(QString("hello") == main.getVariable("obj.name").toString());

  main.evalScript("obj.objectName = 'hello2'");
  QVERIFY(QString("hello2") == main.getVariable("obj.objectName").toString());

}
开发者ID:dbrnz,项目名称:PythonQtCopy,代码行数:11,代码来源:PythonQtTests.cpp

示例10: d

int PyQcsObject::loadDocument(QString name, bool runNow)
{
	QDir d(name);
	d.makeAbsolute();
	qDebug() << d.absolutePath();
	if (!QFile::exists(d.absolutePath())) {
		PythonQtObjectPtr mainContext = PythonQt::self()->getMainModule();
		mainContext.evalScript("print 'File not found.'");
		return -1;
	} else {
		return m_qcs->loadFile(d.absolutePath(), runNow);
	}
}
开发者ID:Ali-I,项目名称:CsoundQt,代码行数:13,代码来源:pyqcsobject.cpp

示例11: PythonQtJob

QList< Calamares::job_ptr >
PythonQtViewStep::jobs() const
{
    QList< Calamares::job_ptr > jobs;

    PythonQtObjectPtr jobsCallable = PythonQt::self()->lookupCallable( m_obj, "jobs" );
    if ( jobsCallable.isNull() )
        return jobs;

    PythonQtObjectPtr response = PythonQt::self()->callAndReturnPyObject( jobsCallable );
    if ( response.isNull() )
        return jobs;

    PythonQtObjectPtr listPopCallable = PythonQt::self()->lookupCallable( response, "pop" );
    if ( listPopCallable.isNull() )
        return jobs;

    forever
    {
        PythonQtObjectPtr aJob = PythonQt::self()->callAndReturnPyObject( listPopCallable, { 0 } );
        if ( aJob.isNull() )
            break;

        jobs.append( Calamares::job_ptr( new PythonQtJob( m_cxt, aJob ) ) );
    }

    return jobs;
}
开发者ID:dgikiller,项目名称:calamares,代码行数:28,代码来源:PythonQtViewStep.cpp

示例12: listWidgetProperties

QVariant PyQcsObject::getWidgetProperty(QString widgetid, QString property, int index)
{
	QStringList properties = listWidgetProperties(widgetid,index);
	if ( properties.contains(property) ) {
		return m_qcs->getWidgetProperty(widgetid, property, index);

	} else {

		QString message="Widget "+widgetid+" does not have property "+property+" available properties are: "+properties.join(", ")+".";
		PythonQtObjectPtr mainContext = PythonQt::self()->getMainModule();
		mainContext.evalScript("print \'"+message+"\'");
	}
	return (int) -1;
}
开发者ID:Ali-I,项目名称:CsoundQt,代码行数:14,代码来源:pyqcsobject.cpp

示例13: strcpy

void PyQcsObject::setCsChannel(QString channel, QString stringValue, int index)
{
	CsoundEngine *e = m_qcs->getEngine(index);
	MYFLT *p;
	if (e != NULL) {
		CSOUND *cs = e->getCsound();
		if (cs != NULL && !(csoundGetChannelPtr(cs, &p, channel.toLocal8Bit().constData(), CSOUND_STRING_CHANNEL | CSOUND_INPUT_CHANNEL))) {
			// FIXME not thread safe and not checking string bounds.
			strcpy((char*) p,stringValue.toLocal8Bit().constData() );
			return;
		}
	}
	QString message="Could not set string into channel "+ channel;
	PythonQtObjectPtr mainContext = PythonQt::self()->getMainModule();
	mainContext.evalScript("print \'"+message+"\'");
}
开发者ID:Ali-I,项目名称:CsoundQt,代码行数:16,代码来源:pyqcsobject.cpp

示例14: lookupAndCall

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 );
}
开发者ID:dgikiller,项目名称:calamares,代码行数:19,代码来源:PythonQtUtils.cpp

示例15: main

int main( int argc, char **argv )
{
  QApplication qapp(argc, argv);

  PythonQt::init(PythonQt::IgnoreSiteModule | PythonQt::RedirectStdOut);
  PythonQt_QtAll::init();

  PythonQtObjectPtr  mainContext = PythonQt::self()->getMainModule();
  PythonQtScriptingConsole console(NULL, mainContext);

  // add a QObject to the namespace of the main python context
  PyExampleObject example;
  mainContext.addObject("example", &example);

  mainContext.evalFile(":example.py");

  console.show();
  return qapp.exec();
}
开发者ID:SelimJB,项目名称:Projet-mancho,代码行数:19,代码来源:main.cpp


注:本文中的PythonQtObjectPtr类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。