QCustomPlot Discussion and Comments

Error compiling on MacOS 11.6, Xcode 12.5.1, Qt 6.2.0-rcReturn to overview

Since Qt 6.2.0-rc was released recently, which is the first version to natively support MacOS arm64, I started porting my application. However, I'm getting the following error when compiling QCustomPlot:

moc_qcustomplot.cpp:249:35: error: unexpected namespace name 'QCP': expected expression
, QtPrivate::TypeAndForceComplete<QCP, std::true_type>

More information is given below. I'm not sure where the error occurs. Is it a problem in Qt/MOC? Or in QCustomPlot? I'm having no problems on MacOS x86_64 and Qt 5.15. Any advice how to get it to compile would be appreciated.

The code in the moc_qcustomplot.cpp file:

const QMetaObject QCP::staticMetaObject = { {
    nullptr,
    qt_meta_stringdata_QCP.offsetsAndSize,
    qt_meta_data_QCP,
    nullptr,
    nullptr,
qt_incomplete_metaTypeArray<qt_meta_stringdata_QCP_t
, QtPrivate::TypeAndForceComplete<QCP, std::true_type>



>,
    nullptr
} };

And this is the beginning of the section in QCustomPlot.h defining the namespace QCP (Q_MOC_RUN seems to be not defined, the #else block is greyed out):

/*!
  The QCP Namespace contains general enums, QFlags and functions used throughout the QCustomPlot
  library.
  
  It provides QMetaObject-based reflection of its enums and flags via \a QCP::staticMetaObject.
*/
#ifndef Q_MOC_RUN
namespace QCP {
#else
class QCP { // when in moc-run, make it look like a class, so we get Q_GADGET, Q_ENUMS/Q_FLAGS features in namespace
  Q_GADGET
  Q_ENUMS(ExportPen)
  [...]
  Q_ENUMS(SelectionType)
public:
#endif
...

This is a known issue with QCustomPlot and Qt6.2 and I suspect that it will be fixed once Qt 6.2 is actually released.

I did manage to get it to compile with a quick-and-dirty hack replacing QtPrivate::TypeAndForceComplete<QCP, std::true_type> with null but I have no idea what other problems this will cause, and I only did it to prove that other parts of my program were working (although everything seemed to work!)

Thanks

Phil

Thanks a lot for your feedback. Your workaround will allow me to complete the port to arm64, even if it temporarily breaks QCustomPlot. That is great news for me!

Nic

Still no solution? Replacing QtPrivate::TypeAndForceComplete<QCP, std::true_type> with null does not work:

const QMetaObject QCP::staticMetaObject = { {
    nullptr,
    qt_meta_stringdata_QCP.offsetsAndSize,
    qt_meta_data_QCP,
    nullptr,
    nullptr,
qt_incomplete_metaTypeArray<qt_meta_stringdata_QCP_t
, NULL
//, QtPrivate::TypeAndForceComplete<QCP, std::true_type>



>,
    nullptr
} };

you need 6.2 compatible version - check this forum thread:
https://www.qcustomplot.com/index.php/support/forum/2380

also replacing it with nullptr isnt exactly a good idea...

it'll work for you.