Results 1 to 5 of 5

Thread: QMetaType usage

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2006
    Posts
    11
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanked 1 Time in 1 Post

    Default QMetaType usage

    Hi,

    I have a non-Qt type that I am trying to use in a signal/slot connection. I would like to do the following:

    In Header

    Qt Code:
    1. class MyClass
    2. {
    3. ...
    4. signals:
    5. void negotiate( const unsigned int& timeout, const eos::ResourceSetRequest& request );
    6. ...
    7. }
    To copy to clipboard, switch view to plain text mode 

    In CPP

    Qt Code:
    1. void MyClass::someFunction()
    2. {
    3. emit negotiate( timeout, request );
    4. }
    To copy to clipboard, switch view to plain text mode 

    However, when I try this the connection isn't being made. From the documentation it looks like I need to register the type eos::ResourceSetRequest as a QMetaType before it can be sent as a signal argument.

    Is this correct?

    If so, then how do I register the non-Qt type as a new QMetaType?

    It looks like I need to place the following in the CPP file:
    Qt Code:
    1. Q_DECLARE_METATYPE(eos::ResourceSetRequest);
    2. int reqID = qRegisterMetaType<eos::ResourceSetRequest>("eos::ResourceSetRequest");
    To copy to clipboard, switch view to plain text mode 

    However, when I do this I get the following compile error:
    c:\Qt\4.1.4\include\QtCore\../../src\corelib\kernel\qmetatype.h(85) : error C2512: 'eos::ResourceSetRequest' : no appropriate default constructor available
    c:\Qt\4.1.4\include\QtCore\../../src\corelib\kernel\qmetatype.h(97) : see reference to function template instantiation 'void *qMetaTypeConstructHelper<T>(const T *)' being compiled
    with
    [
    T=eos::ResourceSetRequest
    ]
    DeviceQResourceFrame.cpp(22) : see reference to function template instantiation 'int qRegisterMetaType<eos::ResourceSetRequest>(const char *,T *)' being compiled
    with
    [
    T=eos::ResourceSetRequest
    ]

    Is this a Qt problem or a problem with constructing the non-Qt class?

    Any advice on this would be greatly appreciated.
    Last edited by wysota; 20th December 2006 at 11:12. Reason: missing [code] tags

Similar Threads

  1. Reducing CPU Usage
    By Kapil in forum Qt Programming
    Replies: 8
    Last Post: 3rd April 2011, 15:43
  2. QEffects.cpp usage.....
    By Naveen in forum Qt Programming
    Replies: 6
    Last Post: 11th January 2011, 12:07
  3. Qt4 XML usage
    By kandalf in forum Qt Programming
    Replies: 1
    Last Post: 21st November 2006, 21:18
  4. QList usage in place QPtrList
    By darpan in forum Qt Programming
    Replies: 2
    Last Post: 25th October 2006, 16:41
  5. Usage of the Debugger!!
    By Kapil in forum Qt Programming
    Replies: 9
    Last Post: 20th April 2006, 05:48

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.