PDA

View Full Version : invalid use of incomplete type ‘struct QPair<QString, QDate>’



TheQuest
11th October 2009, 19:43
I'm trying to learn how to program in C++ with Qt4.5. I am sure I am missing something but I cannot understand the following compiler message:

birthday.cpp: In member function ‘bool Birthday::append(const QString&, const QDate&)’:
birthday.cpp:22: error: invalid use of incomplete type ‘struct QPair<QString, QDate>’

The incriminated code is just this

bool Birthday::append( const QString& name, const QDate& date )
{
...
QPair<const QString&, const QDate&> data = qMakePair( name, date );
...
}

Thanks in advance to everyone who will reply.

fabio

codebehind
11th October 2009, 21:29
the document (file:///usr/lib64/qt-4.4.1/doc/html/qpair.html#qMakePair) said
that you have to use append.
in your case:

QPair<const QString&, const QDate&> data;
data.append(qMakePair( name, date ));

codebehind
11th October 2009, 21:32
sorry i forgot something:

QList<QPair<const QString&, const QDate&> > data;
data.append(qMakePair( name, date ));

TheQuest
11th October 2009, 22:41
sorry i forgot something:

QList<QPair<const QString&, const QDate&> > data;
data.append(qMakePair( name, date ));

How is what you wrote related to my code? Where have you seen a QList to append any QPair to?

Please, stick to my code and to the related compiler error.

codebehind
12th October 2009, 19:36
sorry! i just copied the example....

well, i tried the next code and it works:

void append( const QString& name, const QDate& date )
{
QPair<QString,QDate> data = qMakePair( name, date );
}
or


void append( const QString& name, const QDate& date )
{
QPair<QString,QDate> data( name, date );
}