Results 1 to 3 of 3

Thread: class constructor

  1. #1
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default class constructor

    Hi,

    I have a class like that:

    Qt Code:
    1. class A
    2. A(QHash<QSrting,QVariant>); //Constructor
    To copy to clipboard, switch view to plain text mode 

    But the compiler is getting me "class without constructors" when trying to create a "A" class object.

    Wich is the problem? I'm able to use a constrctor getting an "int" as parameter but it seems to not like the QHash parameter?

    Thanks,
    Òscar Llarch i Galán

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: class constructor

    works fine for me
    Qt Code:
    1. #include <QHash>
    2. #include <QVariant>
    3.  
    4. class A
    5. {
    6. public:
    7. A(QHash<QString, QVariant> &hash) : m_hash(hash) {}
    8.  
    9. private:
    10. QHash<QString, QVariant> m_hash;
    11. };
    12.  
    13. ...
    14. QHash<QString, QVariant> h;
    15. A a(h);
    16. ...
    To copy to clipboard, switch view to plain text mode 
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. #3
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: class constructor

    Hi,

    Ups, just a mistake on inheritance.

    Thanks,
    Òscar Llarch i Galán

Similar Threads

  1. class QHBoxLayout
    By csvivek in forum Installation and Deployment
    Replies: 2
    Last Post: 10th April 2008, 07:57
  2. default parameters in constructor class
    By mickey in forum General Programming
    Replies: 4
    Last Post: 23rd February 2008, 18:44
  3. How to use Signal through direct connection
    By santosh.kumar in forum Qt Programming
    Replies: 1
    Last Post: 14th December 2007, 07:07
  4. Delayed Rendering of QTabWidget Tabs
    By mclark in forum Qt Tools
    Replies: 13
    Last Post: 14th May 2007, 22:53
  5. Replies: 2
    Last Post: 4th May 2006, 19:17

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.