Nope, that didn't do the trick. I changed my code to look like this and scriptEngineLoaded is set to true, but the result is still the same. Also from the Qt code I read I believe the VBScript engine is set automatically internally when a script ending in vbs is loaded.
int main(int argc, char *argv[])
{
QAxScript *m_helloWorld
= m_manager.
load("C:\\test.vbs",
"HelloWorld");
if (m_helloWorld)
m_helloWorld->call("helloWorld");
else
qDebug() << "didn't load";
}
int main(int argc, char *argv[])
{
bool scriptEngineLoaded = QAxScriptManager::registerEngine("VBScript", "vbs");
QAxScriptManager m_manager;
QAxScript *m_helloWorld = m_manager.load("C:\\test.vbs", "HelloWorld");
if (m_helloWorld)
m_helloWorld->call("helloWorld");
else
qDebug() << "didn't load";
}
To copy to clipboard, switch view to plain text mode
Added after 47 minutes:
Ah, I found some very uselful documentation on http://crpppc19.epfl.ch/doc/qt4-doc-...container.html and after reading through the testcon example http://crpppc19.epfl.ch/doc/qt4-doc-...t-testcon.html (find the code in your qt installation directory under tools/activeqt/testcon) I got it working.
#include <QAxScriptManager>
#include <QDebug>
#include <QWidget>
#include <QApplication>
int main(int argc, char *argv[])
{
// Some QObject is crucial. If the script manager is not initialized with a QObject* then call() will return "Unknown Error"
QAxScript *m_helloWorld
= m_manager
->load
("C:\\test.vbs",
"HelloWorld");
if (m_helloWorld)
m_helloWorld->call("helloWorld()"); // don't forget () for a function without params.
else
qDebug() << "didn't load";
// cleanup code missing
return a.exec();
}
#include <QAxScriptManager>
#include <QDebug>
#include <QWidget>
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
// Some QObject is crucial. If the script manager is not initialized with a QObject* then call() will return "Unknown Error"
QWidget *widget = new QWidget();
QAxScriptManager *m_manager = new QAxScriptManager(widget);
QAxScript *m_helloWorld = m_manager->load("C:\\test.vbs", "HelloWorld");
if (m_helloWorld)
m_helloWorld->call("helloWorld()"); // don't forget () for a function without params.
else
qDebug() << "didn't load";
// cleanup code missing
return a.exec();
}
To copy to clipboard, switch view to plain text mode
Edited: removed doubled part of post
Bookmarks