QCustomPlot Discussion and Comments

Compile with new QCP2.0.0Return to overview

Hi everybody,

First, thanks DerManu for this incredible librairy !!!

Second, for those of you who have a project that include the "windows.h" file, you won't be able to compile the new librairy since there's a mismatch of the "max()" macro. There's some workaround you can easily find on Google but here's what I did :

Change the line 4293 :
double minDistSqr = std::numeric_limits<double>::max();

with this :
double minDistSqr = (std::numeric_limits<double>::max)();

So I just wrapped the call with parenthesis (to prevents the macro expansion)

As far as I know it's common practice to define the macro
#define NOMINMAX
before including Windows.h for this reason. This is a problem for all programs that use the standard template library, on Microsoft Windows.
(See Microsoft support article)

Nevertheless I'll note this in my todo list for the next patch. Less friction when setting up is always better, even if it's not QCP/STLs fault :)

Yeah! you're right! We should have use the #define at first ! :P

After cleaning and rebuilding my project with QCP2.0.0 , I'm now facing the a linker problem with QCPLayoutElement, more precisely the "setSizeConstraintRect" function...

moc_qcustomplot.obj:-1: error: LNK2001: unresolved external symbol "public: void __cdecl QCPLayoutElement::setSizeConstraintRect(enum QCPLayoutElement::SizeConstraintRect)" (?setSizeConstraintRect@QCPLayoutElement@@QEAAXW4SizeConstraintRect@1@@Z)

if I comment the line 1190 :
Q_PROPERTY(SizeConstraintRect sizeConstraintRect READ sizeConstraintRect WRITE setSizeConstraintRect)

I'm able to compile, everything seems to work fine until I try to close my program and delete a QCPLayoutElement, it crash with the message :

Debug Error !


HEAP CORRUPTION DETECTED: after Normal block(#294177) at 0x00000.......... CRT detected that the application wrote to memory after end of heap buffer.

Does somebody had this linker problem... and how should I solve it... ???

I also had some linker problem related to these virtual functions :

virtual QSize minimumOuterSizeHint() const;
virtual QSize maximumOuterSizeHint() const;

which I had to reimplement in my custom classes that inherited from QCPAxisRect. but after implementing them, the errors were gone except the one for the setSizeContraintRect in qcustomplot....

Any help would be much appreciated !

Nevermind, just found out that there was 2 include of qcustomplot, and I only change the files at one place !

Gave me a scare, man! :)

Sorry, should always double/triple check before asking for help !

Linker errors are always a nightmare ahahhaha
Thanks again DerManu !