Results 1 to 2 of 2

Thread: [[SOLVED]]Can't get data from QVector

  1. #1
    Join Date
    Sep 2006
    Posts
    23
    Thanks
    4
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Android

    Default [[SOLVED]]Can't get data from QVector

    Hello.

    I've a class that contains a QVector and an integer.
    Qt Code:
    1. Class.h
    2. Public:
    3. QVector<int> vector;
    4. int integer;
    5.  
    6. class(int, int); //the second one is the length of the vector
    To copy to clipboard, switch view to plain text mode 
    I create a class from main
    Qt Code:
    1. class(2,5)
    To copy to clipboard, switch view to plain text mode 
    It creates a random QVector,
    but then i can't access from main:
    Qt Code:
    1. class.integer; //works great
    2. class.vector.size();// tells me 0, and the constructor has show me the values iterating trough the vector.
    To copy to clipboard, switch view to plain text mode 
    Of course I've #include <QVector> in both of them.

    I've created a method to print the contents of the vector from the class and it shows the vector empty. So it seems that the vector does not save the data, only in the constructor.

    class.print(); //no data, vector.size() = 0;

    What am I missing?

    Thank you in advance.

    Asier

    I've found the mistake.
    It was a scope error,
    In the implementation file I had again: QVector<int> vector. and it was no necessary since I had declared in the class.h file
    Last edited by asieriko; 13th December 2009 at 20:01. Reason: updated contents

  2. #2
    Join Date
    Jul 2009
    Location
    Enschede, Netherlands
    Posts
    462
    Thanked 69 Times in 67 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Can't get data from QVector

    Please post the implementation of your constructor. It is impossible to tell what you've missed when the relevant code isn't there.
    Horse sense is the thing that keeps horses from betting on people. --W.C. Fields

    Ask Smart Questions

Similar Threads

  1. Data class concept
    By qtDave in forum General Programming
    Replies: 2
    Last Post: 19th December 2009, 09:41
  2. data rate transfer is decreasing in TCP connection
    By navi1084 in forum Qt Programming
    Replies: 3
    Last Post: 19th June 2009, 16:15
  3. Best way to display lots of data fast
    By New2QT in forum Newbie
    Replies: 4
    Last Post: 16th October 2008, 22:46
  4. Replies: 7
    Last Post: 29th August 2008, 10:24
  5. QVector Explosion
    By baray98 in forum General Programming
    Replies: 1
    Last Post: 11th November 2007, 15:12

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.