QCustomPlot Discussion and Comments

Compiling without RTTI support (Windows CE or other resource constraint devices)Return to overview

Hi all,

First, well done to the authors of the library, I'm impressed by its quality.

I've been using the library on a Windows CE 6 device and QT 4.8, without RTTI support. Because of this, I couldn't cross compile the library, as the dynamic_cast operator is not supported in my setup. I've found a workaround solution that may be useful for other people. I'm using version 1.0.0-beta, downloaded on July 11 2013.

I'm using virtual functions in order to replace the dynamic_cast, as described in http://thewayofc.blogspot.ie/2007/09/alternative-ways-to-implement-downcasts.html.

I performed the following modifications:

qcustomplot.h:

class QCP_LIB_DECL QCPItemAnchor
{
public:
  ...
  virtual QCPItemPosition* isQCPItemPosition() { return 0; }
  ...
};

...

class QCP_LIB_DECL QCPItemPosition : public QCPItemAnchor
{
public:
  ...
  virtual QCPItemPosition* isQCPItemPosition() { return this; }
  ...
};

qcustomplot.cpp:

// Replace line:
//if (QCPItemPosition *currentParentPos = dynamic_cast<QCPItemPosition*>(currentParent))
// by:
if (QCPItemPosition *currentParentPos = currentParent->isQCPItemPosition())

Hope this helps someone.

The plot examples work perfectly on my Desktop machine.

For some reason examples 10 and 15 do not work properly on Windows CE, not sure why yet (cannot remote-debug). Any suggestion regarding this would be appreciated :)


Antony

It was originally intended to keep no-RTTI support. Consequently I've incorporated a patch which removes those few dynamic_cast calls accordingly. Thanks for mentioning that.

About the WinCE issue:
Is it possible that QDateTime::toMSecsSinceEpoch() doesn't properly work on WinCE? Maybe you could test that with a minimal program that continuously outputs values from that function.
What exactly do you observe in the demos that don't work?

Hi,

Just came back to the forum. I have written my program on PC but haven't tested it yet on WinCE. I will test QDateTime::toMSecsSinceEpoch() and will let you know.

Antony