Results 1 to 18 of 18

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

  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?

  12. #12
    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 of my thread and don't pass "this" to the constructor of the socket, doens't the socket be a "stand_alone" object?
    But still it will be living in a different thread.

    Afterward i call delete serverSocket in the destructor of the thread.
    You could use QObject::deleteLater() (if it's possible) or delete in just before run() returns.

    There is also QObject::moveToThread().

    And why this doesn't work with qt 4.1.0 but instead it works with 4.1.0?
    I don't know, but you should get a lot of warnings on the console.

  13. #13
    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'

    Thank you very much!
    I created the socket in the run() method and now all works good.

  14. #14
    Join Date
    Feb 2006
    Location
    USA
    Posts
    142
    Thanks
    24
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

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

    I'm suffering from this same problem, and I have a single-threaded application.

    I invoke QTcpSocket in a separate class as a static object with no parent (attempting to set a parent after it has been instantiated seems to confuse QObject and create free() errors on shutdown). An entirely different class then takes this socket and tries to make it connect to a remote server.

    Here's what the connection looks like:
    Qt Code:
    1. QTcpSocket * mySocket = &formBasePlugin::socketServer;
    2. mySocket->connectToHost(ui.lineEditHost->text(), ui.spinBoxPort->value(), QIODevice::ReadWrite);
    To copy to clipboard, switch view to plain text mode 
    Life without passion is death in disguise

  15. #15
    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 KShots View Post
    a static object with no parent
    http://www.trolltech.com/developer/t...entry&id=90881

    Quote Originally Posted by KShots View Post
    attempting to set a parent after it has been instantiated seems to confuse QObject and create free() errors on shutdown
    Every QObject that has a parent will be deleted when it's parent gets destroyed, but on the other hand you can't delete static objects. So either make that object non-static or reparent it again.

  16. The following user says thank you to jacek for this useful post:

    KShots (8th February 2007)

  17. #16
    Join Date
    Feb 2006
    Location
    USA
    Posts
    142
    Thanks
    24
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

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

    Ah, I think I see the problem, then. Although they fixed the bug you mention in 4.2.0, I am using 4.1.4 (latest version available that plays nice with dbus). So... I'll see if I can find a way to make this thing work without a static socket. Thanks!
    Life without passion is death in disguise

  18. #17
    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 KShots View Post
    I'll see if I can find a way to make this thing work without a static socket.
    Maybe QObject::moveToThread() will be enough?

  19. The following user says thank you to jacek for this useful post:

    KShots (8th February 2007)

  20. #18
    Join Date
    Feb 2006
    Location
    USA
    Posts
    142
    Thanks
    24
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

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

    That worked - the socket is still static, but it is now functional .

    Thanks!
    Life without passion is death in disguise

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.