[Qt-interest] Passing QList<QStringList> as arguments

David Villalobos Cambronero david.villalobos.c at gmail.com
Tue Aug 24 21:58:30 CEST 2010


Thanks to all the people that help me with your comments. I implements the
Hellen & Alex solution and it seems to work at the moment.

#ifndef MYSQLTOPCLASS_H
#define MYSQLTOPCLASS_H

#include <QList>
#include <QStringList>

class QSqlQuery;
class QVariant;
class QString;
//class QStringList;
//class QList<class QStringList>;

class mysqlTopClass
{
public:
    mysqlTopClass();

    //Global variables
    QSqlQuery *query;

    //Global methods
    QVariant runQuery(QString queryToExecute);
    QVariant runQuery(QString queryToExecute, int column);
    QString fixedWidth(QString text, int width);
    QString outputAsTable(const QStringList *headers, const
QList<QStringList> *rows);
};

#endif // MYSQLTOPCLASS_H

Again thanks a lot.


Regards
---
David


On Tue, Aug 24, 2010 at 13:47, Malyushytsky, Alex <alex at wai.com> wrote:

>  As somebody mentioned  place where you put your includes is important.
>
>
>
> >> ror: variable ‘QList<QStringList> rows’ has initializer but incomplete
> type
>
>
>
> An error below might be related to usage forward declaration
>
> (for example no includes yet, but compiler already need to know about type
> to proceed)
>
>
>
> The easiest way to check it place all includes in the header file where you
> declare the function.
>
>  Alex
>
>
>
>
>
>
>
>
>
> *From:* qt-interest-bounces at trolltech.com [mailto:
> qt-interest-bounces at trolltech.com] *On Behalf Of *David Villalobos
> Cambronero
> *Sent:* Tuesday, August 24, 2010 10:38 AM
>
> *To:* Andre Somers
> *Cc:* qt-interest at trolltech.com
> *Subject:* Re: [Qt-interest] Passing QList<QStringList> as arguments
>
>
>
> Those are my headers:
>
>
> #include <QtGui>
> #include <QList>
> #include <QString>
> #include <QStringList>
>
> and still got he error.
>
>
> Regards
> ---
> David
>
>  On Tue, Aug 24, 2010 at 11:31, Andre Somers <andre at familiesomers.nl>
> wrote:
>
>  Op 24-8-2010 19:24, David Villalobos Cambronero schreef:
>
> > Hi all, hope you can help me.
> >
> > Here is the scenario:
> >
> > I need to pass a function a QList<QStringList> param. I take a look at
> > the nestedlayouts example, basically it has the following lines:
> >
> > QList<QStringList> rows = QList<QStringList>()
> > << (QStringList() << "Verne Nilsen" << "123")
> > << (QStringList() << "Carlos Tang" << "77")
> > << (QStringList() << "Bronwyn Hawcroft" << "119")
> > << (QStringList() << "Alessandro Hanssen" << "32")
> > << (QStringList() << "Andrew John Bakken" << "54")
> > << (QStringList() << "Vanessa Weatherley" << "85")
> > << (QStringList() << "Rebecca Dickens" << "17")
> > << (QStringList() << "David Bradley" << "42")
> > << (QStringList() << "Knut Walters" << "25")
> > << (QStringList() << "Andrea Jones" << "34");
> >
> > I can run the example without any problem. But if I copy and paste
> > these two lines in my proyect:.
> > QList<QStringList> rows = QList<QStringList>()
> > << (QStringList() << "Verne Nilsen" << "123");
> >
> > I got he followin error:
> > error: variable ‘QList<QStringList> rows’ has initializer but
> > incomplete type
> > error: invalid use of incomplete type ‘class QList<QStringList>’
> >
> > The example and my project both uses QtGui.
>
> Sounds like you did not copy over the needed #include's as well. Your
> compiler has currently no idea what a QList<QStringList> is supposed to
> be. You need to point it to the place where it can find that.
>
> André
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>
>
>
>
> ---------------------------------------------------------------------------------------------------
> Weidlinger Associates, Inc. made the following annotations.
>
> “This message and any attachments are solely for the intended recipient and
> may contain confidential or privileged information. If you are not the
> intended recipient, any disclosure, copying, use, or distribution of the
> information included in this message and any attachments is prohibited. If
> you have received this communication in error, please notify us by reply
> e-mail and immediately and permanently delete this message and any
> attachments. Thank you.”
>
> “Please consider our environment before printing this email.”
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100824/c4470b0e/attachment.html 


More information about the Qt-interest-old mailing list