Results 1 to 5 of 5

Thread: C# codes transfer to QT with QaxObject

  1. #1
    Join Date
    Apr 2016
    Posts
    9
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Windows

    Question C# codes transfer to QT with QaxObject

    My C# code with ActiveX Webbrowser:
    Qt Code:
    1. webBrowser1.Document.GetElementsByTagName("A")[5];
    To copy to clipboard, switch view to plain text mode 

    I tried to make a program with activeX Webbrowser. The webBrowser1 is the name of ACTIVEX control. And I succeeded in C# with VS 2015 IDE. And now I need to work it out in C++ with QT frame(version 5.6).

    and this is my attempt code:

    Qt Code:
    1. QAxObject* myEles = MyWebObj->querySubObject("Document");
    2. QAxObject* myEle = myEles->querySubObject("GetElementsByTagName(const Qstring&)", "A");
    To copy to clipboard, switch view to plain text mode 
    It seems that it can get Document correctly,but fail whatever next subobject is---it can compile successfully,but get error when running. It is really weird as I get everything right with ActiveX Excel with the same method.

    I wonder what is wrong here.It is appreciated if someone can do it with the very ActiveX webbrowser.
    And I wonder how to write to pick the element from a group with QT; Just like the example: I need to pick the 5th element. How to write it with QT?

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: C# codes transfer to QT with QaxObject

    I have no experience with either ActiveX or ActiveQt, but are you sure that "Qstring" is an ActiveX type and that the function returns a single object (sounds like it would return a list of sorts).

    Also, if you need access to DOM elements, maybe use a browser engine that has a Qt interface?
    Or run the queries on the HTML side and communicate the results to the application with QWebChannel?
    Or write the query code in C# and communicate the results to the Qt application?

    Cheers,
    _

  3. The following user says thank you to anda_skoa for this useful post:

    DJW602 (14th June 2016)

  4. #3
    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: C# codes transfer to QT with QaxObject

    GetElementsByTagName() is a method of the Document object, not a sub-object. In all likelihood you want something like this:
    Qt Code:
    1. QAxObject* myDoc = MyWebObj->querySubObject("Document");
    2. QVariant myEles = myDoc->dynamicCall("GetElementsByTagName(const QString&)", "A");
    To copy to clipboard, switch view to plain text mode 
    Note the captialisation of QString. I do not know how you would access the list that myEles represents

  5. #4
    Join Date
    Apr 2016
    Posts
    9
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: C# codes transfer to QT with QaxObject

    Thanks. Indeed, I wrote qstring in a wrong way. But still I stuck at how to get access to a certain element from a bulk of objects. =_=

  6. #5
    Join Date
    Apr 2016
    Posts
    9
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Windows

    Exclamation Re: C# codes transfer to QT with QaxObject

    I have to say I still get stuck here. I tried many ways to solve it,but only failed.T_T I just can 't believe I got stuck for just a grammar problem. No wonder someone says that C++ is inefficient. ::>_<::

Similar Threads

  1. Replies: 2
    Last Post: 22nd April 2011, 00:39
  2. ISO 639-2 language codes
    By brixton in forum Qt Programming
    Replies: 2
    Last Post: 23rd November 2010, 21:52
  3. Replies: 1
    Last Post: 5th November 2010, 05:22
  4. QR codes
    By jcr in forum General Programming
    Replies: 0
    Last Post: 16th May 2006, 05:02
  5. Key codes
    By impeteperry in forum Qt Programming
    Replies: 4
    Last Post: 28th April 2006, 18:35

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.