Results 1 to 4 of 4

Thread: Better way to initialize QVector

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2009
    Posts
    17
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Windows

    Default Better way to initialize QVector

    I guess my question is more about C++ then Qt, but I'm not sure.

    I have a class, and it has a member that is a QVector<type>

    I want to initialize it inside the Class Constructor. After some tries, I got one working:

    variableName = QVector<type>::QVector<type>(0);

    Qt Code:
    1. .h
    2. class Protocol
    3. {
    4. ...
    5. typedef int second;
    6. typedef QVector<second> conj_seconds;
    7. ...
    8. Private:
    9. conj_seconds list_seconds;
    10. ...
    11. }
    12.  
    13.  
    14. .cpp
    15. Protocol::Protocol()
    16. {
    17. ...
    18. list_seconds = QVector<second>::QVector<second>(0);
    19. ...
    20. }
    To copy to clipboard, switch view to plain text mode 

    Is there a more... efficient way? elegant way? It seems so... brute to me

    and,
    another question,
    I can't seem to be able to use "conj_seconds" as a return parameter for my methods. Any ideas why?
    (yes, I included "protocol.h", and <QVector>)

    thank you!

    *Edit*
    actually, No typedef name can be used as a return parameter, but they work fine as other parameters...
    Last edited by lyucs; 20th August 2009 at 15:46.

Similar Threads

  1. Replies: 2
    Last Post: 1st May 2009, 07:35
  2. QVector copy constructor
    By Caius Aérobus in forum Qt Programming
    Replies: 3
    Last Post: 3rd March 2008, 17:52
  3. Problem with qvector
    By zorro68 in forum Qt Programming
    Replies: 1
    Last Post: 23rd February 2008, 01:02
  4. QVector and QSetting
    By mattia in forum Newbie
    Replies: 1
    Last Post: 8th November 2007, 16:21
  5. QVector
    By sabeesh in forum Qt Programming
    Replies: 2
    Last Post: 17th September 2007, 14:37

Tags for this Thread

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
  •  
Qt is a trademark of The Qt Company.