PDA

View Full Version : QMap as function argument...



cydside
18th April 2009, 15:18
Hi to All,
I'm passing a QMap parameter as follow:

frmExample.h



class frmExample : public QDialog
{
Q_OBJECT

public:
class frmExample(const QMap <QString, QVariant> &Names, QWidget *parent=0);
//...
}


frmExample.cpp



frmExample::frmExample(const QMap <QString, QVariant> &Names, QWidget *parent) : QDialog(parent)
{
ui.setupUi(this);
//...
}


and the compiler returns:



frmExample.cpp:1 error expected unqualified id before "const"
frmExample.cpp:1 error expected ')' before "const" :confused:


I remember that it's possible to pass abstract type as argument in C++, isn't it?

thanks

lyuts
18th April 2009, 16:59
What does this mean in your class?


public:
class frmExample(const QMap <QString, QVariant> &Names, QWidget *parent=0);



looks like keyword `class` needs to be removed.

cydside
18th April 2009, 17:15
What does this mean in your class?


public:
class frmExample(const QMap <QString, QVariant> &Names, QWidget *parent=0);



looks like keyword `class` needs to be removed.

Yes, it's a typing error in that post, yuo'd to read as follow:



class frmExample : public QDialog
{
Q_OBJECT

public:
frmExample(const QMap <QString, QVariant> &Names, QWidget *parent=0);
//...
}

lyuts
18th April 2009, 17:27
Strange, I don't have such problem. I just tried this.
Did you include QMap's header?

jpn
18th April 2009, 17:27
What if you #include <QVariant> and use QVariantMap?

cydside
18th April 2009, 17:59
Sorry, I notiiced that in my code was:



frmExample(const QMap <QString, QVariant> &Names, QWidget *parent) : QDialog(parent)
{
ui.setupUi(this);
//...
}


simply I forgot the statement frmExample::frmExample while I posted right previous!

I'm so sorry, I need to rest, yes!

thanks to all!