Page 1 of 7 123 ... LastLast
Results 1 to 20 of 121

Thread: dynamicCall and QByteArray - strange characters

  1. #1
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    691
    Thanks
    59
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default dynamicCall and QByteArray - strange characters

    Hi to all,
    doing some test with a com object seems that a com routine that I call with dynamicCall returns a QByteArray or a QString.
    Looking at examples of call of such routine seems that it returns an array of bytes where every element is a pointer to a string

    I did some tests as this:

    QByteArray array = obj->dynamicCall("routine(QString)", "value").toByteArray();
    Debugging with visual studio and doing some cout ( qDebug() << array.data() ) I can see very strange characters like this "‰*" in both case, using QByteArray and QString.
    The routine called with dymanicCall comunicate with a chinese fingerprint reader. Maybe this is the reason I get such strange characters?

    Looking at doc and visual basic example the value returned should be an array of bytes -> returned_value[value1,value2,value3, value4..];

    and

    value1 = value2 = value3 = should points to a string.

    How can I get the value of every value without getting these strange characters?
    I hope to get help wysota where are you?

    Regards
    Last edited by franco.amato; 17th April 2010 at 18:03.
    Franco Amato

  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: dynamicCall and QByteArray - strange characters

    Can you run the dumpcpp utility against the com object you are working with?
    Qt Code:
    1. cd somewheresafetowrite
    2. dumpcpp c:\windows\system32\comctl32.ocx
    To copy to clipboard, switch view to plain text mode 
    The resulting cpp and h file should allow you to more directly access the COM objects by simply instantiating them in the typical C++ fashion:
    Qt Code:
    1. ComctlLib::TreeView m_treeView;
    2. ...
    3. m_treeView.SetBorderStyle(ComctlLib::ccFixedSingle);
    To copy to clipboard, switch view to plain text mode 

    The process can be largely automated by:

    client.pro
    Qt Code:
    1. TEMPLATE = app
    2. CONFIG += qaxcontainer
    3. TARGET = client
    4. DEPENDPATH += .
    5. INCLUDEPATH += .
    6. RC_FILE = client.rc
    7. // {6B7E6392-850A-101B-AFC0-4210102A8DA7} is the TypeLib value from the class concerned.
    8. TYPELIBS = $$system( dumpcpp -getfile {6B7E6392-850A-101B-AFC0-4210102A8DA7} )
    9. isEmpty(TYPELIBS) {
    10. message("Tree control type library not found!")
    11. REQUIRES += COMCTL.TreeView
    12. }
    13. else: {# Input
    14. SOURCES += main.cpp
    15. }
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    691
    Thanks
    59
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: dynamicCall and QByteArray - strange characters

    Quote Originally Posted by ChrisW67 View Post
    Can you run the dumpcpp utility against the com object you are working with?
    Qt Code:
    1. cd somewheresafetowrite
    2. dumpcpp c:\windows\system32\comctl32.ocx
    To copy to clipboard, switch view to plain text mode 
    The resulting cpp and h file should allow you to more directly access the COM objects by simply instantiating them in the typical C++ fashion:
    Qt Code:
    1. ComctlLib::TreeView m_treeView;
    2. ...
    3. m_treeView.SetBorderStyle(ComctlLib::ccFixedSingle);
    To copy to clipboard, switch view to plain text mode 

    The process can be largely automated by:

    client.pro
    Qt Code:
    1. TEMPLATE = app
    2. CONFIG += qaxcontainer
    3. TARGET = client
    4. DEPENDPATH += .
    5. INCLUDEPATH += .
    6. RC_FILE = client.rc
    7. // {6B7E6392-850A-101B-AFC0-4210102A8DA7} is the TypeLib value from the class concerned.
    8. TYPELIBS = $$system( dumpcpp -getfile {6B7E6392-850A-101B-AFC0-4210102A8DA7} )
    9. isEmpty(TYPELIBS) {
    10. message("Tree control type library not found!")
    11. REQUIRES += COMCTL.TreeView
    12. }
    13. else: {# Input
    14. SOURCES += main.cpp
    15. }
    To copy to clipboard, switch view to plain text mode 
    Hi,
    I executed the dumpcpp on my dll ( the com object) but it doesn't generated any *.h or *.cpp
    What can I do?

  4. #4
    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: dynamicCall and QByteArray - strange characters

    Did you write the com object yousrself? Using QAxServer? If so you probably have a file ending .tlb as part of the build process, and you can put this file name directly in TYPELIBS.

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: dynamicCall and QByteArray - strange characters

    Quote Originally Posted by franco.amato View Post
    wysota where are you?
    I'm having a bad evening.

    Besides what was already written I could advise you to check the type of variant returned by dynamic call.

    Qt Code:
    1. QVariant var = obj->dynamicCall(...);
    2. qDebug() << var->typeName();
    To copy to clipboard, switch view to plain text mode 

  6. #6
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    691
    Thanks
    59
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: dynamicCall and QByteArray - strange characters

    Quote Originally Posted by ChrisW67 View Post
    Did you write the com object yousrself? Using QAxServer? If so you probably have a file ending .tlb as part of the build process, and you can put this file name directly in TYPELIBS.
    No I didn't write the com object. It com from a finger print sdk I have. I have it in a compiled dll.
    I'm not sure now if I have a tlb file as I'm out of office. If I have it what can I do? And if I don't have it?

  7. #7
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    691
    Thanks
    59
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: dynamicCall and QByteArray - strange characters

    Quote Originally Posted by wysota View Post
    I'm having a bad evening.

    Besides what was already written I could advise you to check the type of variant returned by dynamic call.

    Qt Code:
    1. QVariant var = obj->dynamicCall(...);
    2. qDebug() << var->typeName();
    To copy to clipboard, switch view to plain text mode 
    Ok I'll check tomorrow with the typeName,
    for now thank you.

    Regards

  8. #8
    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: dynamicCall and QByteArray - strange characters

    Quote Originally Posted by franco.amato View Post
    No I didn't write the com object. It com from a finger print sdk I have. I have it in a compiled dll.
    I'm not sure now if I have a tlb file as I'm out of office. If I have it what can I do? And if I don't have it?
    You can try
    Qt Code:
    1. TYPELIBS += C:\path\to\your\fingerprint.dll
    To copy to clipboard, switch view to plain text mode 
    which seems to work OK for me for at least some COM objects.

  9. #9
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    691
    Thanks
    59
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: dynamicCall and QByteArray - strange characters

    Quote Originally Posted by ChrisW67 View Post
    You can try
    Qt Code:
    1. TYPELIBS += C:\path\to\your\fingerprint.dll
    To copy to clipboard, switch view to plain text mode 
    which seems to work OK for me for at least some COM objects.
    If I also have the *.tlb I have to do
    Qt Code:
    1. TYPELIBS += C:\path\to\your\fingerprint.dll
    To copy to clipboard, switch view to plain text mode 
    And
    Qt Code:
    1. TYPELIBS += C:\path\to\your\fingerprint.tlb?
    To copy to clipboard, switch view to plain text mode 

  10. #10
    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: dynamicCall and QByteArray - strange characters

    If you have the TLB file then list it otherwise try listing the DLL or OCX file itself. One or the other, not both.

  11. #11
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    691
    Thanks
    59
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: dynamicCall and QByteArray - strange characters

    Quote Originally Posted by wysota View Post
    I'm having a bad evening.

    Besides what was already written I could advise you to check the type of variant returned by dynamic call.

    Qt Code:
    1. QVariant var = obj->dynamicCall(...);
    2. qDebug() << var->typeName();
    To copy to clipboard, switch view to plain text mode 
    Dear Wysota the result of the
    Qt Code:
    1. qDebug() << var->typeName();
    To copy to clipboard, switch view to plain text mode 
    is QByteArray but I don't know how to manage the data. It returns strange characters.

    I also generated the *.cpp and *.h files with dumpcpp.
    This is the prototype of the routine that give problems to me (from the generated .h):
    Qt Code:
    1. /*
    2.   Method GetUserData
    3. */
    4. inline QVariant GetUserData(const QString& CardID);
    To copy to clipboard, switch view to plain text mode 

    and the member function implementation ( always in the *.h generated )
    Qt Code:
    1. inline QVariant oTerminal::GetUserData(const QString& CardID)
    2. {
    3. QVariant qax_result;
    4. void *_a[] = {(void*)&qax_result, (void*)&CardID};
    5. qt_metacall(QMetaObject::InvokeMetaMethod, 71, _a);
    6. return qax_result;
    7. }
    To copy to clipboard, switch view to plain text mode 


    I attached here a shot of the visual studio to see the returned value. I hope you can help me.

    Regards
    Attached Images Attached Images
    Last edited by franco.amato; 20th April 2010 at 17:48.
    Franco Amato

  12. #12
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    691
    Thanks
    59
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: dynamicCall and QByteArray - strange characters

    Quote Originally Posted by ChrisW67 View Post
    The resulting cpp and h file should allow you to more directly access the COM objects by simply instantiating them in the typical C++ fashion:
    Qt Code:
    1. ComctlLib::TreeView m_treeView;
    2. ...
    3. m_treeView.SetBorderStyle(ComctlLib::ccFixedSingle);
    To copy to clipboard, switch view to plain text mode 
    Hi, I don't understand a thing:
    I don't have to use the new operator to instantiate the objects?

  13. #13
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: dynamicCall and QByteArray - strange characters

    Let's ask this first - what would you expect the byte array to contain?

  14. #14
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    691
    Thanks
    59
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: dynamicCall and QByteArray - strange characters

    Quote Originally Posted by wysota View Post
    Let's ask this first - what would you expect the byte array to contain?
    Wysota here the very poor doc I have respect to such routine:

    Function: GetUserData
    Parameter: CardID(string/10)
    Description: Get User Data
    Return values: ArrayList

    So I expect some sort of array list with different fields as the "set" routine accepts these parameters:

    Function: SetUserData
    Parameters:
    CardID(string/10)
    OverWrite(0: no overwrite. If ID is already registered, return with result 06.,1: overwrite.)
    idxDesignation
    idxDepartment
    FirstName(string /15)
    LastName(string /15)
    idxGroup (integer/0~255)
    Status(1 : Activate, 0 : Deactivate)
    WorkMode(0:finger+pass ,1:finger,2ass,3:finger or pass,4:Only Crad,5:Only from external Reader,6:Matching on Mifare card)
    WorkTimeStart()
    WorkTimeEnd()
    EmployeeID
    RegisterMode( Finger =1, Password = 2, Finger and Password = 3, Card=4, Max=4)
    CheckExpire
    ExpireDateStart
    ExpireDateEnd
    Password(string/10)
    NF(Number of fingerprint data per user Max. 2)
    TemplateSize
    FingerData (byte,User Fingerprint data total size depends on the number of fingerprints registered per user)

    Description: Set User Data
    Return values: True: Successfully

    I think the Get routine should returns the same parameters I pass in the Set routine.

    Best Regards
    Franco Amato

  15. #15
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: dynamicCall and QByteArray - strange characters

    Maybe you didn't call the routine correctly and it reports some error or something like that?

  16. #16
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    691
    Thanks
    59
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: dynamicCall and QByteArray - strange characters

    Quote Originally Posted by wysota View Post
    Maybe you didn't call the routine correctly and it reports some error or something like that?
    No I have no errors, and also visual studio says the QByteArray has a size of 441 elements.
    I'm thinking to do a com wrapper in c# and call the com routine from it to see the result but from my Qt code how can I get the parameters?

  17. #17
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: dynamicCall and QByteArray - strange characters

    Quote Originally Posted by franco.amato View Post
    No I have no errors, and also visual studio says the QByteArray has a size of 441 elements.
    So maybe everything is there? Try casting the contents of the array to the structure you should be getting and reading the data.

  18. #18
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    691
    Thanks
    59
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: dynamicCall and QByteArray - strange characters

    Quote Originally Posted by wysota View Post
    So maybe everything is there? Try casting the contents of the array to the structure you should be getting and reading the data.
    I don't have such structure. How can I do it?

  19. #19
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: dynamicCall and QByteArray - strange characters

    I meant the ArrayList (or its C++ equivalent) or whatever the return type of the call should be.

  20. #20
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    691
    Thanks
    59
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: dynamicCall and QByteArray - strange characters

    Quote Originally Posted by wysota View Post
    I meant the ArrayList (or its C++ equivalent) or whatever the return type of the call should be.
    Do you mean something like this?
    QList<QString> list = static_cast<QList<QString>>(ba.data()) ?

Similar Threads

  1. Replies: 0
    Last Post: 16th April 2010, 23:21
  2. Regarding qbytearray
    By mohanakrishnan in forum Qt Programming
    Replies: 7
    Last Post: 19th November 2009, 13:38
  3. Replies: 9
    Last Post: 25th July 2009, 13:27
  4. Replies: 1
    Last Post: 28th May 2008, 16:52
  5. QByteArray in Qt3
    By joseph in forum Qt Programming
    Replies: 1
    Last Post: 6th September 2007, 06:16

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.