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:
case 73:
switch (*reinterpret_cast<int*>(_a[1])) {
default: *reinterpret_cast<int*>(_a[0]) = -1; break;
case 0:
*reinterpret_cast<int
*>
(_a
[0]) = qRegisterMetaType<
QMouseEvent* >
();
break;
}
break;
case 73:
switch (*reinterpret_cast<int*>(_a[1])) {
default: *reinterpret_cast<int*>(_a[0]) = -1; break;
case 0:
*reinterpret_cast<int*>(_a[0]) = qRegisterMetaType< QMouseEvent* >(); break;
}
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:
{
if (event->button() == Qt::RightButton) {
LOG_QMSG("Right button click");
tr("Image files (*.png)"));
if (fileName.compare("") == 0) {
return;
}
colony_plot->savePng(fileName);
}
}
void MainWindow::clickedGraph(QMouseEvent *event)
{
if (event->button() == Qt::RightButton) {
LOG_QMSG("Right button click");
QString fileName = QFileDialog::getSaveFileName(this, tr("Select image file"), ".",
tr("Image files (*.png)"));
if (fileName.compare("") == 0) {
return;
}
colony_plot->savePng(fileName);
}
}
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.
Bookmarks