Results 1 to 5 of 5

Thread: invalid use of incomplete type ‘struct QPair<QString, QDate>’

  1. #1

    Default 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

  2. #2
    Join Date
    Apr 2007
    Posts
    76
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: invalid use of incomplete type ‘struct QPair<QString, QDate>’

    the document said
    that you have to use append.
    in your case:
    Qt Code:
    1. QPair<const QString&, const QDate&> data;
    2. data.append(qMakePair( name, date ));
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Apr 2007
    Posts
    76
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: invalid use of incomplete type ‘struct QPair<QString, QDate>’

    sorry i forgot something:
    Qt Code:
    1. QList<QPair<const QString&, const QDate&> > data;
    2. data.append(qMakePair( name, date ));
    To copy to clipboard, switch view to plain text mode 

  4. #4

    Default Re: invalid use of incomplete type ‘struct QPair<QString, QDate>’

    Quote Originally Posted by codebehind View Post
    sorry i forgot something:
    Qt Code:
    1. QList<QPair<const QString&, const QDate&> > data;
    2. data.append(qMakePair( name, date ));
    To copy to clipboard, switch view to plain text mode 
    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.

  5. #5
    Join Date
    Apr 2007
    Posts
    76
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default 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:
    Qt Code:
    1. void append( const QString& name, const QDate& date )
    2. {
    3. QPair<QString,QDate> data = qMakePair( name, date );
    4. }
    To copy to clipboard, switch view to plain text mode 
    or
    Qt Code:
    1. void append( const QString& name, const QDate& date )
    2. {
    3. QPair<QString,QDate> data( name, date );
    4. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Compile 4.4.0
    By LordQt in forum Installation and Deployment
    Replies: 18
    Last Post: 29th May 2008, 13:43
  2. problem with forward declaration
    By MarkoSan in forum General Programming
    Replies: 14
    Last Post: 6th January 2008, 21:45
  3. Client/Server Error: BadIDChoice
    By 3nc31 in forum Qt Programming
    Replies: 5
    Last Post: 27th November 2007, 10:22
  4. Make error with Qt Jambi 4.3.2_01
    By pamalite in forum Installation and Deployment
    Replies: 0
    Last Post: 22nd November 2007, 12:05

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.