QCustomPlot Discussion and Comments

QCPDocument example file gives error: expected unqualified-id before 'struct'Return to overview

Hi, I'm trying to get the text-document interaction example to compile on Windows 7, Qt5.2.1. It worked fine on CentOS with Qt 4.6.2.
When I compile I get the error:
expected unqualified-id before 'struct'
for row 41.

    QCPDocumentObject *interface = new QCPDocumentObject(this);

I'm using the example files and haven't modified anything. Anybody got a solution to this problem?

Just tested it on WinXP (GCC, Qt 4.7.4) and it works without trouble. I'm not sure what's going on. Is the type QCPDocumentObject properly known in your code, i.e. is qcpdocumentobject.cpp correctly included?

Try testing it with Qt 5.2.1
As I mentioned, I haven't modified anything. I imported the project file into Qt Creator and compiled it.

Got the same issue on Windows 7, MinGW and Qt 5.2.0.
Did anyone find out a solution (other than downgrading Qt version ?) or the root cause of this issue ?

Problem solved, change "QCPDocument interface" name to "QCPDocument interface2" or whatever variable name you whant to use. interface is already used.

Afaik interface isn't a reserved word in c++. What exactly did you do to make it work? Did you have to rename the class qcpdocumentobject?

Problem solved, change "QCPDocumentObject *interface" name to "QCPDocumentObject *interface2" and (QCPDocumentObject::PlotTextFormat, interface) to (QCPDocumentObject::PlotTextFormat, interface2)

This is the new code:

// register the plot document object (only needed once, no matter how many plots will be in the QTextDocument):

QCPDocumentObject *interface2 = new QCPDocumentObject(this);
ui->textEdit->document()->documentLayout()->registerHandler(QCPDocumentObject::PlotTextFormat, interface2);

If you include <windows.h>, the name "interface" is used in one of its internal included headers. I got the same issue and had to rename my own "interface" member name to something else.