Results 1 to 18 of 18

Thread: QMetaObject::invokeMethod: Unable to handle unregistered datatype 'quit16'

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    La Spezia,Italy
    Posts
    77
    Thanks
    9
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QMetaObject::invokeMethod: Unable to handle unregistered datatype 'quint16'

    Hello, I had a working program with Qt 4.0.1. I have upgraded to Qt 4.1.0 and now I got the error in the title when I try to use the connectToHost() command.
    I'm using kdevelop 3.2, I have erased the old Makefiles and ran qmake.
    I have also set the new PATH in my bash.profile.

    Any hint?

    Thanks
    Last edited by vratojr; 22nd February 2006 at 17:35.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QMetaObject::invokeMethod: Unable to handle unregistered datatype 'quit16'

    Try:
    Qt Code:
    1. qRegisterMetaType<quint16>("quint16");
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Jan 2006
    Location
    La Spezia,Italy
    Posts
    77
    Thanks
    9
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QMetaObject::invokeMethod: Unable to handle unregistered datatype 'quit16'

    Quote Originally Posted by jacek
    Try:
    Qt Code:
    1. qRegisterMetaType<quint16>("quint16");
    To copy to clipboard, switch view to plain text mode 
    I tryed but then I got the same message but with 'OpenMode' unregistered...

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QMetaObject::invokeMethod: Unable to handle unregistered datatype 'quit16'

    Quote Originally Posted by vratojr
    I tryed but then I got the same message but with 'OpenMode' unregistered...
    Are you sure that your program worked with Qt 4.0.1? Maybe it was 4.0.0?

    In Qt 4.0.1 there was a slight change in SLOT and SIGNAL macros:
    Qt 4.0.0 introduced a change to the way type names outside the current
    scope were handled in signals and slots declarations and connections
    which differed from the behavior in Qt 3.x.

    Unfortunately, this could lead to signal-slot connections that were
    potentially type-unsafe. Therefore, in Qt 4.0.1 type names must be fully
    qualified in signal-slot declarations and connections.

    For example, in Qt 4.0.0, it was possible to write:

    connect(socket, SIGNAL(error(SocketError)), ...);

    In Qt 4.0.1, the above connection must be made in the following way:

    connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), ...);

  5. #5
    Join Date
    Jan 2006
    Location
    La Spezia,Italy
    Posts
    77
    Thanks
    9
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QMetaObject::invokeMethod: Unable to handle unregistered datatype 'quit16'

    Quote Originally Posted by jacek
    Are you sure that your program worked with Qt 4.0.1? Maybe it was 4.0.0?

    In Qt 4.0.1 there was a slight change in SLOT and SIGNAL macros:
    Yes,I'm sure. The directory I use is called Qt 4.0.1 and I use the syntax that you wrote above. Moreover, the problem that I get doesn't come from a "connect" macro.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QMetaObject::invokeMethod: Unable to handle unregistered datatype 'quit16'

    Could you post the line where you invoke that connectToHost() method? Do you use threads?

  7. #7
    Join Date
    Jan 2006
    Location
    La Spezia,Italy
    Posts
    77
    Thanks
    9
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QMetaObject::invokeMethod: Unable to handle unregistered datatype 'quit16'

    Quote Originally Posted by jacek
    Could you post the line where you invoke that connectToHost() method? Do you use threads?
    Yes:
    Qt Code:
    1. serverSocket->connectToHost("5.244.185.198",1111);
    To copy to clipboard, switch view to plain text mode 

    I call it in the run() function of a thread.

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QMetaObject::invokeMethod: Unable to handle unregistered datatype 'quit16'

    Quote Originally Posted by vratojr
    I call it in the run() function of a thread.
    Where do you create the object that serverSocket points to?

  9. #9
    Join Date
    Jan 2006
    Location
    La Spezia,Italy
    Posts
    77
    Thanks
    9
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QMetaObject::invokeMethod: Unable to handle unregistered datatype 'quit16'

    The structure of the program is:

    Socket is a sublcass of tcpsocket,I symply rewrote the write and read methods.

    class UserThread : public QThread{
    ....
    private:
    Socket *serverSocket;
    ...
    }

    In the constructor I call:

    serverSocket = new Socket();

    then, in run I call the connectToHost().

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QMetaObject::invokeMethod: Unable to handle unregistered datatype 'quit16'

    Quote Originally Posted by vratojr
    In the constructor I call:

    serverSocket = new Socket();

    then, in run I call the connectToHost().
    So the problem is that your serverSocket was created in a different thread (the one that created the thread object). You should instantiate this socket in the run() method.

  11. #11
    Join Date
    Jan 2006
    Location
    La Spezia,Italy
    Posts
    77
    Thanks
    9
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QMetaObject::invokeMethod: Unable to handle unregistered datatype 'quit16'

    Quote Originally Posted by jacek
    So the problem is that your serverSocket was created in a different thread (the one that created the thread object). You should instantiate this socket in the run() method.
    But, I read that the problem arises when the socket is son of a different thread,no? If I call
    Qt Code:
    1. serverSocket = new Socket()
    To copy to clipboard, switch view to plain text mode 
    in the constructor of my thread and don't pass "this" to the constructor of the socket, doens't the socket be a "stand_alone" object?
    Afterward i call
    Qt Code:
    1. delete serverSocket
    To copy to clipboard, switch view to plain text mode 
    in the destructor of the thread.

    And why this doesn't work with qt 4.1.0 but instead it works with 4.1.0?

Similar Threads

  1. Replies: 4
    Last Post: 4th July 2012, 07:37
  2. How to Compile VTKDesigner2 with Qt?
    By alfredoaal in forum Newbie
    Replies: 0
    Last Post: 5th September 2008, 05:34
  3. Replies: 3
    Last Post: 18th May 2008, 18:36

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.