Results 1 to 12 of 12

Thread: Q_DECLARE_METATYPE problem

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    Join Date
    Mar 2010
    Location
    Auckland, NZ
    Posts
    121
    Thanks
    9
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Q_DECLARE_METATYPE problem

    Thanks for looking at this. The situation now is even more confusing. I have removed MyQGraphicsView from the program, which eliminated that error. But after adding back most of the rest of the code (I started with a very stripped-down version of the program I am converting over from Qt4 to Qt5) I am getting the same Q_DECLARE_METATYPE error, but now I can't see where it is coming from. These are the 5 lines of error messages:

    F:\Qt\5.13.0\msvc2017\include\QtCore\qmetatype.h:1 798: error: C2338: Type is not registered, please use the Q_DECLARE_METATYPE macro to make it known to Qt's meta-object system
    F:\Qt\5.13.0\msvc2017\include\QtCore\qmetatype.h:1 805: see reference to function template instantiation 'int qMetaTypeId<T>(void)' being compiled
    with
    [
    T=QMouseEvent *
    ]
    D:\testing\build-vspheroid-Qt3d\release\moc_mainwindow.cpp:686: see reference to function template instantiation 'int qRegisterMetaType<QMouseEvent*>(void)' being compiled
    F:\Qt\5.13.0\msvc2017\include\QtCore\qatomic.h:56: see reference to class template instantiation 'QBasicAtomicInteger<int>' being compiled
    F:\Qt\5.13.0\msvc2017\include\QtCore\qatomic.h:154 : see reference to class template instantiation 'QAtomicInteger<int>' being compiled

    The relevant code in moc_mainwindow.cpp is:
    Qt Code:
    1. case 73:
    2. switch (*reinterpret_cast<int*>(_a[1])) {
    3. default: *reinterpret_cast<int*>(_a[0]) = -1; break;
    4. case 0:
    5. *reinterpret_cast<int*>(_a[0]) = qRegisterMetaType< QMouseEvent* >(); break;
    6. }
    7. break;
    To copy to clipboard, switch view to plain text mode 

    i.e. again reference to QMouseEvent. The file mainwindow.cpp is quite long, a couple of thousand lines, and I have no idea what part of the code is generating this error. There is no indication of what is causing the error. I have cleaned everything, run qmake and rebuilt (many times).

    Edit: I have discovered that the error is triggered by this function:

    Qt Code:
    1. void MainWindow::clickedGraph(QMouseEvent *event)
    2. {
    3. if (event->button() == Qt::RightButton) {
    4. LOG_QMSG("Right button click");
    5. QString fileName = QFileDialog::getSaveFileName(this, tr("Select image file"), ".",
    6. tr("Image files (*.png)"));
    7. if (fileName.compare("") == 0) {
    8. return;
    9. }
    10. colony_plot->savePng(fileName);
    11. }
    12. }
    To copy to clipboard, switch view to plain text mode 

    specifically, it appears, by the function argument. There doesn't seem to be anything unusual about this.
    Last edited by gib; 19th August 2019 at 12:48.

Similar Threads

  1. Q_DECLARE_METATYPE(T); error
    By SentaVera in forum Qt Programming
    Replies: 3
    Last Post: 2nd January 2014, 14:40
  2. Q_DECLARE_METATYPE() questions.
    By hickscorp in forum Qt Programming
    Replies: 1
    Last Post: 29th June 2010, 16:04
  3. Problem to declare a stl map - Q_DECLARE_METATYPE
    By Althor in forum Qt Programming
    Replies: 5
    Last Post: 9th December 2008, 09:41
  4. How to use Q_DECLARE_METATYPE
    By lni in forum Qt Programming
    Replies: 6
    Last Post: 21st July 2008, 17:13
  5. Q_DECLARE_METATYPE and qVariantCanConvert
    By manojmka in forum Qt Programming
    Replies: 1
    Last Post: 1st April 2008, 06:13

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.