Results 1 to 2 of 2

Thread: Problem regarding QVector

  1. #1
    Join Date
    Aug 2008
    Posts
    84
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Problem regarding QVector

    Hi ,I am working on Qt4.4.I came across one problem with QVector.I declared a vector containing another vector of type QString.
    Qt Code:
    1. QVector<QVector<QString> *>mainvec;
    To copy to clipboard, switch view to plain text mode 

    Now I want to insert data into vector ie I want to insert 50*50 data into vector mainvec .for that the code i used is

    Qt Code:
    1. 1 for (int i = 0; i < 50; ++i)
    2. 2 for (int j = 0; j < 50; ++j)
    3. 3 data[i]->push_back("data");
    To copy to clipboard, switch view to plain text mode 

    if I do this my execution was breaking when it comes to the line 3.
    So please help me to solve the problem

    With Regards,
    Sudheer.

  2. #2
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Problem regarding QVector

    i) you insert into a QVector (*data[i] ) that you never allocated!

    ii) just use a QList<QStringList>; that is easier and less error prone.

    HTH

Similar Threads

  1. signal-slot problem with QVector
    By stefan in forum Qt Programming
    Replies: 1
    Last Post: 12th October 2008, 13:58
  2. Weird problem: multithread QT app kills my linux
    By Ishark in forum Qt Programming
    Replies: 2
    Last Post: 8th August 2008, 09:12
  3. QVector copy constructor
    By Caius Aérobus in forum Qt Programming
    Replies: 3
    Last Post: 3rd March 2008, 17:52
  4. Problem with qvector
    By zorro68 in forum Qt Programming
    Replies: 1
    Last Post: 23rd February 2008, 01:02
  5. QVector problem
    By kingslee in forum Qt Programming
    Replies: 5
    Last Post: 19th October 2006, 10:42

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.