Results 1 to 9 of 9

Thread: COM object and QtVariant casting issue

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2017
    Location
    Spain
    Posts
    5
    Thanks
    4
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: COM object and QtVariant casting issue

    Hi, thankyou for answer.

    I've tried how you say with error: error: '__mingw_uuidof' was not declared in this scope
    Qt Code:
    1. QVariant var = JswAttrList.GetItem(Some_attribute);
    2. HRESULT hr = AttrList.queryInterface(__uuidof(JSWSCAPILib::IJswAttrList),(void **)&var);
    To copy to clipboard, switch view to plain text mode 
    __uuidof is a MVC++ extensión. I have to say that I am using mingw as compiler. Them I've tried to get UUID Class from Visual C++ with this simple test:
    Qt Code:
    1. String^ s = __uuidof(JSWSCAPILib::IJswAttrList);
    To copy to clipboard, switch view to plain text mode 
    with this compiler error: error C2787: 'SCAPILib::IAttrList' : No GUIDs have been associated with this object

  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: COM object and QtVariant casting issue

    I think (void**)&var does not make sense, that is retinterpreting a pointer to a QVariant, no?

    You write that the QVariant type is IUnknown*, does this compile?
    Qt Code:
    1. IUnknown *obj = var.value<IUnknown*>();
    To copy to clipboard, switch view to plain text mode 

    Cheers,
    _

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

    mlago (4th January 2017)

  4. #3
    Join Date
    Jan 2017
    Location
    Spain
    Posts
    5
    Thanks
    4
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: COM object and QtVariant casting issue

    Thankyou for reply.
    Quote Originally Posted by anda_skoa View Post
    I think (void**)&var does not make sense, that is retinterpreting a pointer to a QVariant, no?
    In a sense yes.
    Quote Originally Posted by anda_skoa View Post
    You write that the QVariant type is IUnknown*, does this compile?
    Qt Code:
    1. IUnknown *obj = var.value<IUnknown*>();
    To copy to clipboard, switch view to plain text mode 

    Cheers,
    _
    Yes, compile Ok. What do you suggest?.
    Last edited by mlago; 4th January 2017 at 17:47.

  5. #4
    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: COM object and QtVariant casting issue

    Quote Originally Posted by mlago View Post
    Yes, compile Ok. What do you suggest?.
    I haven't worked with COM or ActiveQt, but if the object is stored as a IUnknown in the QVariant, then just extract it as such and then use whatever API is provided for working with COM interfaces on that pointer.

    I.e. the QVariant is just a transport wrapper, like an envelope. You take the transported item out of the envelope and forget about the envelope.

    Cheers,
    _

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

    mlago (4th January 2017)

  7. #5
    Join Date
    Jan 2017
    Location
    Spain
    Posts
    5
    Thanks
    4
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: COM object and QtVariant casting issue

    It sounds really easy

    Seriously, I was thinking about something like that but still not know very well as how. What amazes me is that I can not do it any other way.

    I appreciate your effort.

  8. #6
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,328
    Thanks
    317
    Thanked 871 Times in 858 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: COM object and QtVariant casting issue

    I've tried how you say with error: error: '__mingw_uuidof' was not declared in this scope
    So that sounds like mingw knows about it, but you haven't included the header file where it is defined. I don't use mingw, so I can't really tell you where to look. What does Google tell you if you paste "__mingw_uuidof" into the search box?
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

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

    mlago (5th January 2017)

  10. #7
    Join Date
    Jan 2017
    Location
    Spain
    Posts
    5
    Thanks
    4
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: COM object and QtVariant casting issue

    Hi,
    __uuidof is defined in _mingw.h
    Qt Code:
    1. #define __uuidof(type) __mingw_uuidof<__typeof(type)>()
    To copy to clipboard, switch view to plain text mode 
    The _mingw.h file begins by saying:
    Qt Code:
    1. /**
    2.  * This file has no copyright assigned and is placed in the Public Domain.
    3.  * This file is part of the mingw-w64 runtime package.
    4.  * No warranty is given; refer to the file DISCLAIMER.PD within this package.
    5.  */
    To copy to clipboard, switch view to plain text mode 
    and my compiler versión is 32 bits

    The most usable that I found in google is this thread https://forum.qt.io/topic/35324/solv...ce-to-canoe/15, but it is not applicable to me in the same way that it is exposed there. I've already tried compiling it with ole32.lib and nothing has changed.

    As I said I have also tried to capture the value returned by __uuidof in MS visual C ++ with the idea of using that UUID in my application in Qt. From this test what I consider relevant is the returned message by compiler error C2787: 'SCAPILib::IAttrList' : No GUIDs have been associated with this object. Which suggests to me that this class has no definite UUID. Then I have tried to define an IID_IATTRLIST variable in the IAttrList class without getting QueryInterface to return anything other than a null pointer. I think this is a dead end

Similar Threads

  1. casting object to enum in Qt
    By alizadeh91 in forum Qt Programming
    Replies: 1
    Last Post: 18th August 2012, 15:22
  2. Two dynamically created object interaction issue
    By kornicameister in forum Qt Quick
    Replies: 2
    Last Post: 9th September 2011, 11:35
  3. QtVariant pointer from QHash list
    By rmat in forum Qt Programming
    Replies: 3
    Last Post: 9th August 2011, 10:28
  4. Qt Webkit 2.1 - SVG Issue - Object overlapping
    By Tushar in forum Qt Programming
    Replies: 0
    Last Post: 29th December 2010, 08:32
  5. object handling issue
    By prolink007 in forum Qt Programming
    Replies: 1
    Last Post: 12th April 2010, 07:42

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.