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

Eric Clark eclark at ara.com
Tue Aug 24 21:38:14 CEST 2010


The class prototype is your problem. Try changing it to this:

class QList<class QStringList>;

The compiler may barf at this because of the templates, but your class prototype (class QList<QStringList*>) has a pointer in it when it shouldn’t and it does not prototype the QStringList.

Thanks,
Eric

From: David Villalobos Cambronero [mailto:david.villalobos.c at gmail.com]
Sent: Tuesday, August 24, 2010 2:31 PM
To: Eric Clark
Cc: Qt Interest (qt-interest at trolltech.com)
Subject: Re: [Qt-interest] Passing QList<QStringList> as arguments

Thanks for the interest Eric, here is the info.

Header file
------------------------------------------------------------------------------------------------------------------------
#ifndef MYSQLTOPCLASS_H
#define MYSQLTOPCLASS_H

class QList<QStringList *>;

class mysqlTopClass
{
public:
    mysqlTopClass();
    QString outputAsTable(const QStringList *headers, const QList<QStringList> *rows);
};

#endif // MYSQLTOPCLASS_H
------------------------------------------------------------------------------------------------------------------------

Class file
------------------------------------------------------------------------------------------------------------------------
#include <QStringList>
#include <QList>

#include "mysqltopclass.h"

mysqlTopClass::mysqlTopClass()
{
}

QString mysqlTopClass::outputAsTable(const QStringList *headers, const QList<QStringList> *rows)
{
  return "Gelow";
}
------------------------------------------------------------------------------------------------------------------------

Here is where I use it
------------------------------------------------------------------------------------------------------------------------

#include <QtGui>

#include "serverInformation.h"
#include "mysqlClasses/mysql.h"
#include "ui_dialog.h"

serverInformation::serverInformation()
{
  mysql *conn = new mysql;

  QStringList *headers = new QStringList("-V,(**.)");
  headers->append("David");
  headers->append("Vil");
  headers->append("Vil");
  QList<QStringList> *rows = new QList<QStringList *>;
  rows->append(new QStringList("David V"));
  QPlainTextEdit *replicationStatus = new QPlainTextEdit(conn->outputAsTable(headers, rows));
  replicationStatus->setFont(font);
  replicationStatus->setWordWrapMode(QTextOption::NoWrap);
  addTab(replicationStatus, QIcon(":/images/images/16/Replication.png"), tr("Replication Status"));
}


Hope it helps. If not, I can send you a copy of my project.

---
David
On Tue, Aug 24, 2010 at 13:13, Eric Clark <eclark at ara.com<mailto:eclark at ara.com>> wrote:
David,

You mentioned that this is a function that you are passing the list to correct? Can you show us the declaration of the function, and the definition and tell us where the includes are at? For example, are the includes only in the cpp file and the declaration of the function is in the header without the includes?

Thanks,
Eric

From: qt-interest-bounces at trolltech.com<mailto:qt-interest-bounces at trolltech.com> [mailto:qt-interest-bounces at trolltech.com<mailto:qt-interest-bounces at trolltech.com>] On Behalf Of David Villalobos Cambronero
Sent: Tuesday, August 24, 2010 12:38 PM
To: Andre Somers
Cc: qt-interest at trolltech.com<mailto: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<mailto: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<mailto:Qt-interest at trolltech.com>
http://lists.trolltech.com/mailman/listinfo/qt-interest


_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com<mailto: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/fb49cb99/attachment.html 


More information about the Qt-interest-old mailing list