Results 1 to 4 of 4

Thread: QAxScriptManager not returning a QAxScript* for VBScript

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2012
    Posts
    9
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QAxScriptManager not returning a QAxScript* for VBScript

    Hi,

    I'm trying to call a VBScript from within Qt and set up a small test application:

    Qt Code:
    1. #include <QAxScriptManager>
    2. #include <QDebug>
    3.  
    4. int main(int argc, char *argv[])
    5. {
    6. QAxScriptManager m_manager;
    7. QAxScript *m_helloWorld = m_manager.load("C:\\test.vbs", "HelloWorld");
    8. if (m_helloWorld)
    9. m_helloWorld->call("helloWorld");
    10. else
    11. qDebug() << "didn't load";
    12. }
    To copy to clipboard, switch view to plain text mode 

    The VBScript is at the right place on C:\test.vbs and looks like this:

    Qt Code:
    1. Function helloWorld()
    2. msgbox("Hello World")
    3. End Function
    To copy to clipboard, switch view to plain text mode 

    Now when I compile and run this I don't get a QAxScript back from the QAxScriptManager. Stepping through the code I learned that the file is read and a QAxScript object created, but in the load function on it its isValid() function returns false because the internal member 'engine' is not set and therefore later the object is discarded and a NULL pointer returned. But I couldn't find where 'engine' would ever be set.

    Can you please help me understand what I am doing wrong?
    Or give me some example code?

    Cheers
    Jan

    Edited: typo

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QAxScriptManager not returning a QAxScript* for VBScript

    QAxScriptManager::registerEngine() looks promising (a guess, not from experience). I don't know exactly what you would send it, but I would try:
    Qt Code:
    1. QAxScriptManager::registerEngine("vbs", "VBScript");
    To copy to clipboard, switch view to plain text mode 
    where "VBScript" is the ProgId of the VBSCript in process server.

Similar Threads

  1. QAxScriptManager
    By virus in forum Newbie
    Replies: 0
    Last Post: 22nd March 2011, 14:33
  2. Returning const &
    By frenk_castle in forum Newbie
    Replies: 2
    Last Post: 24th November 2009, 07:01
  3. zoomRectangle returning null
    By Raghaw in forum Qwt
    Replies: 0
    Last Post: 3rd November 2009, 12:52
  4. SelectFile() is returning NULL
    By abhilashajha in forum Qt Programming
    Replies: 6
    Last Post: 10th June 2009, 11:30
  5. returning a string
    By mickey in forum General Programming
    Replies: 2
    Last Post: 3rd February 2008, 19:41

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.