Results 1 to 16 of 16

Thread: ActiveQt QVariant and VC VARIANT

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2008
    Location
    TaganrogNativelandChehov,Russia
    Posts
    64
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    1
    Thanked 8 Times in 7 Posts

    Default Re: ActiveQt QVariant and VC VARIANT

    QVariant qVariantFromValue ( const T & value )
    QVariant QVariant::fromValue ( const T & value ) [static]
    ?
    and
    QVariant::QVariant ( int typeOrUserType, const void * copy )
    void QVariant::setValue ( const T & value )
    T QVariant::value () const
    ?
    east or west home is best

  2. #2
    Join Date
    Dec 2008
    Location
    TaganrogNativelandChehov,Russia
    Posts
    64
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    1
    Thanked 8 Times in 7 Posts

    Default Re: ActiveQt QVariant and VC VARIANT

    show your code please
    east or west home is best

  3. #3
    Join Date
    Aug 2009
    Posts
    52
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanked 10 Times in 10 Posts

    Default Re: ActiveQt QVariant and VC VARIANT

    Qt Code:
    1. mint->dynamicCall("DoGo(int, QVariant)", QVariantList()<<3<<QVariant(QVariantList()<<0<<1<<2));
    To copy to clipboard, switch view to plain text mode 

    Or

    Qt Code:
    1. short aaa[3] = {0,1,2};
    2. mint->dynamicCall("DoGo(int, QVariant)", QVariantList()<<3<<QVariant(QMetaType::Short,(void *)aaa));
    To copy to clipboard, switch view to plain text mode 

    will get runtime error:

    QAxBase: Error calling IDispatch member DoGo: Unknown error

    Qt Code:
    1. short aaa[3] = {0,1,2};
    2. QVariant params;
    3. params.setValue(aa);
    To copy to clipboard, switch view to plain text mode 

    will get compile error:
    error C2039: 'qt_metatype_id' : is not a member of 'QMetaTypeId<T>'

  4. #4
    Join Date
    Dec 2008
    Location
    TaganrogNativelandChehov,Russia
    Posts
    64
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    1
    Thanked 8 Times in 7 Posts

    Default Re: ActiveQt QVariant and VC VARIANT

    Quote Originally Posted by dbzhang800 View Post
    2
    3



    short aaa[3] = {0,1,2};
    QVariant params;
    params.setValue(aa);

    may be.
    Qt Code:
    1. QVector<int> vec;
    2. vec<<10<<20<<30;
    3. var.setValue(vec);
    To copy to clipboard, switch view to plain text mode 
    east or west home is best

  5. #5
    Join Date
    Aug 2009
    Posts
    52
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanked 10 Times in 10 Posts

    Default Re: ActiveQt QVariant and VC VARIANT

    Qt Code:
    1. QVector<int> vec;
    2. vec<<10<<20<<30;
    3. QVariant var;
    4. var.setValue(vec);
    To copy to clipboard, switch view to plain text mode 

    but the code still does not work

    Qt Code:
    1. d:\qt\4.5.2-msvc\include\qtcore\../../src/corelib/kernel/qmetatype.h(189) : error C2039: 'qt_metatype_id' : is not a member of 'QMetaTypeId<T>'
    2. with
    3. [
    4. T=QVector<int>
    5. ]
    To copy to clipboard, switch view to plain text mode 

  6. #6
    Join Date
    Dec 2008
    Location
    TaganrogNativelandChehov,Russia
    Posts
    64
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    1
    Thanked 8 Times in 7 Posts

    Default Re: ActiveQt QVariant and VC VARIANT

    oh-ho-ho
    read about setValue().
    assistant tell you about it.
    east or west home is best

  7. #7
    Join Date
    Aug 2009
    Posts
    52
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanked 10 Times in 10 Posts

    Default Re: ActiveQt QVariant and VC VARIANT

    The function info:
    DoGo
    Named Params = u'nNumberOfAxes, nAxisArray'
    Return Type = 'Void'
    Argument = 'Integer 2'
    Argument = 'Variant'
    Function kind = 'Dispatch'
    Invoke Kind = 'Function'
    Number Optional Params = 0
    and i try to use queryInterface.

    Other function which without a VARIANT parameter works fine.
    But this one, I still do not know how to deal with the VARIANT

    Qt Code:
    1. IUnknown *iface = 0;
    2. mint->queryInterface(IID_IUnknown, (void**)&iface);
    3. if (iface)
    4. {
    5. short axes[3]={0,1,2};
    6. VARIANTARG v[2];
    7. v[1].iVal = 3;
    8. v[1].vt = VT_I2;
    9. v[0].piVal = axes
    10. v[0].vt = VT_BYREF|VT_I2;
    11.  
    12. DISPPARAMS params = {v, NULL, 2, 0};
    13.  
    14. iface->Invoke(dispid, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD,&params ,NULL, NULL, NULL);
    15. }
    To copy to clipboard, switch view to plain text mode 

    any idea?

  8. #8
    Join Date
    Aug 2009
    Posts
    52
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanked 10 Times in 10 Posts

    Default Re: ActiveQt QVariant and VC VARIANT

    The following code works now.

    Qt Code:
    1. IUnknown *iface = 0;
    2. mint->queryInterface(IID_IUnknown, (void**)&iface);
    3. if (iface)
    4. {
    5. DISPID dispid;
    6. OLECHAR * dispname = L"DoGo";
    7. iface->GetIDsOfNames(IID_NULL, &dispname, 1, LOCALE_USER_DEFAULT, &dispid);
    8.  
    9. short axes0[3]={0,1,2};
    10. SAFEARRAY *axes;
    11. SAFEARRAYBOUND axesbound[1];
    12. axesbound[0].lLbound = 0;
    13. axesbound[0].cElements = 3;
    14. axes = ::SafeArrayCreate(VT_I2, 1, axesbound);
    15. for(long index=0;index<3;index++)
    16. {
    17. ::SafeArrayPutElement(axes,&index,axes0+index);
    18. }
    19.  
    20. VARIANTARG v[2];
    21. v[1].iVal = 3; //number of axes
    22. v[1].vt = VT_I2;
    23. v[0].parray = axes;
    24. v[0].vt = VT_ARRAY|VT_I2;
    25.  
    26. DISPPARAMS params = {v, NULL, 2, 0};
    27.  
    28. iface->Invoke(dispid, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD,&params ,NULL, NULL, NULL);
    29. }
    To copy to clipboard, switch view to plain text mode 

    but I still do not know hou to deal with it through ActiveQt method.
    Qt Code:
    1. QVariantList params = ...
    2. object->dynamicCall("DoGo(int, QVariant)", params);
    To copy to clipboard, switch view to plain text mode 

  9. The following user says thank you to dbzhang800 for this useful post:

    Maxbester (19th June 2013)

  10. #9
    Join Date
    Dec 2008
    Location
    TaganrogNativelandChehov,Russia
    Posts
    64
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    1
    Thanked 8 Times in 7 Posts

    Default Re: ActiveQt QVariant and VC VARIANT

    in files
    E:\Qt\4.5.2\src\activeqt\shared\qaxtypes.cpp
    function
    QVariant VARIANTToQVariant(const VARIANT &arg, const QByteArray &typeName, uint type)
    help you to understand how yuo must do it.
    see the code.
    east or west home is best

  11. #10
    Join Date
    Dec 2008
    Location
    TaganrogNativelandChehov,Russia
    Posts
    64
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    1
    Thanked 8 Times in 7 Posts

    Default Re: ActiveQt QVariant and VC VARIANT

    east or west home is best

  12. #11
    Join Date
    Jan 2013
    Posts
    6
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    2

    Default Re: ActiveQt QVariant and VC VARIANT

    Your link is dead. Could you update it? Thanks.


    Added after 52 minutes:


    Quote Originally Posted by dbzhang800 View Post
    The following code works now.

    Qt Code:
    1. IUnknown *iface = 0;
    2. mint->queryInterface(IID_IUnknown, (void**)&iface);
    3. if (iface)
    4. {
    5. // ...
    6. }
    To copy to clipboard, switch view to plain text mode 
    Could you comment a bit your code? Thanks
    Last edited by Maxbester; 19th June 2013 at 13:50.

Similar Threads

  1. Convert between a custom data type wrapped in a QVariant
    By darkadept in forum Qt Programming
    Replies: 2
    Last Post: 17th March 2009, 09:07
  2. Getting Microsoft Word Object to SaveAs
    By jvwebb in forum Newbie
    Replies: 3
    Last Post: 2nd September 2008, 19:27
  3. QVariant custom/user type comparison
    By gri in forum Qt Programming
    Replies: 2
    Last Post: 12th August 2008, 14:36
  4. Replies: 8
    Last Post: 16th July 2008, 14:05
  5. Crash caused by QVariant (mis)use
    By mclark in forum Newbie
    Replies: 2
    Last Post: 31st October 2006, 15:05

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.