Results 1 to 6 of 6

Thread: QMap as function argument...

  1. #1
    Join Date
    Jun 2008
    Location
    Rome, Italy
    Posts
    95
    Thanks
    19
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default QMap as function argument...

    Hi to All,
    I'm passing a QMap parameter as follow:

    frmExample.h

    Qt Code:
    1. class frmExample : public QDialog
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6. class frmExample(const QMap <QString, QVariant> &Names, QWidget *parent=0);
    7. //...
    8. }
    To copy to clipboard, switch view to plain text mode 

    frmExample.cpp

    Qt Code:
    1. frmExample::frmExample(const QMap <QString, QVariant> &Names, QWidget *parent) : QDialog(parent)
    2. {
    3. ui.setupUi(this);
    4. //...
    5. }
    To copy to clipboard, switch view to plain text mode 

    and the compiler returns:

    Qt Code:
    1. frmExample.cpp:1 error expected unqualified id before "const"
    2. frmExample.cpp:1 error expected ')' before "const" :confused:
    To copy to clipboard, switch view to plain text mode 

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

    thanks

  2. #2
    Join Date
    May 2008
    Location
    Kyiv, Ukraine
    Posts
    418
    Thanks
    1
    Thanked 29 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QMap as function argument...

    What does this mean in your class?
    Qt Code:
    1. public:
    2. class frmExample(const QMap <QString, QVariant> &Names, QWidget *parent=0);
    To copy to clipboard, switch view to plain text mode 

    looks like keyword `class` needs to be removed.
    I'm a rebel in the S.D.G.

  3. #3
    Join Date
    Jun 2008
    Location
    Rome, Italy
    Posts
    95
    Thanks
    19
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QMap as function argument...

    Quote Originally Posted by lyuts View Post
    What does this mean in your class?
    Qt Code:
    1. public:
    2. class frmExample(const QMap <QString, QVariant> &Names, QWidget *parent=0);
    To copy to clipboard, switch view to plain text mode 

    looks like keyword `class` needs to be removed.
    Yes, it's a typing error in that post, yuo'd to read as follow:

    Qt Code:
    1. class frmExample : public QDialog
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6. frmExample(const QMap <QString, QVariant> &Names, QWidget *parent=0);
    7. //...
    8. }
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    May 2008
    Location
    Kyiv, Ukraine
    Posts
    418
    Thanks
    1
    Thanked 29 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QMap as function argument...

    Strange, I don't have such problem. I just tried this.
    Did you include QMap's header?
    I'm a rebel in the S.D.G.

  5. #5
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QMap as function argument...

    What if you #include <QVariant> and use QVariantMap?
    J-P Nurmi

  6. #6
    Join Date
    Jun 2008
    Location
    Rome, Italy
    Posts
    95
    Thanks
    19
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QMap as function argument...

    Sorry, I notiiced that in my code was:

    Qt Code:
    1. frmExample(const QMap <QString, QVariant> &Names, QWidget *parent) : QDialog(parent)
    2. {
    3. ui.setupUi(this);
    4. //...
    5. }
    To copy to clipboard, switch view to plain text mode 

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

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

    thanks to all!

Similar Threads

  1. QPSQL problem
    By LoneWolf in forum Installation and Deployment
    Replies: 60
    Last Post: 4th November 2009, 14:22
  2. Regading Driver to connect Postgresql Database
    By dummystories in forum Installation and Deployment
    Replies: 38
    Last Post: 12th March 2009, 07:19
  3. QPSQL driver in windows
    By brevleq in forum Installation and Deployment
    Replies: 31
    Last Post: 14th December 2007, 12:57
  4. how to add static library into qmake
    By Namrata in forum Qt Tools
    Replies: 1
    Last Post: 20th November 2007, 17:33
  5. use qpsql
    By raphaelf in forum Installation and Deployment
    Replies: 34
    Last Post: 22nd August 2006, 12:52

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.