invalid use of incomplete type ‘struct QPair<QString, QDate>’
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
Re: invalid use of incomplete type ‘struct QPair<QString, QDate>’
the document said
that you have to use append.
in your case:
Code:
QPair<const QString&, const QDate&> data;
data.append(qMakePair( name, date ));
Re: invalid use of incomplete type ‘struct QPair<QString, QDate>’
sorry i forgot something:
Code:
QList<QPair<const QString&, const QDate&> > data;
data.append(qMakePair( name, date ));
Re: invalid use of incomplete type ‘struct QPair<QString, QDate>’
Quote:
Originally Posted by
codebehind
sorry i forgot something:
Code:
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.
Re: invalid use of incomplete type ‘struct QPair<QString, QDate>’
sorry! i just copied the example....
well, i tried the next code and it works:
Code:
void append( const QString& name, const QDate& date )
{
QPair<QString,QDate> data = qMakePair( name, date );
}
or
Code:
void append( const QString& name, const QDate& date )
{
QPair<QString,QDate> data( name, date );
}