Results 1 to 2 of 2

Thread: QVector assignment question

  1. #1
    Join Date
    Oct 2007
    Posts
    11
    Thanks
    4

    Default QVector assignment question

    Hi,

    In Qt3 I used QArray like this:

    Qt Code:
    1. QArray<float> *t;
    2. ...
    3. t = new QArray<float>(day_no+1);
    4. ...
    5. t->at(j) = j+1;
    To copy to clipboard, switch view to plain text mode 

    and that worked. But in Qt4 you cannot do that. So I changed it:

    Qt Code:
    1. QVector<float> t;
    2. ...
    3. t[j] = j+1;
    To copy to clipboard, switch view to plain text mode 

    and that compiles OK but I want to do it like I did in Qt3 and allocate t as new:

    Qt Code:
    1. t = new QVector<float>(day_no+1);
    To copy to clipboard, switch view to plain text mode 

    But how do I do the assignment then like line 3 in the middle chunk of the above?
    Thanks!

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QVector assignment question

    Qt Code:
    1. (*t)[j] = j+1;
    To copy to clipboard, switch view to plain text mode 

  3. The following user says thank you to jacek for this useful post:

    hvw59601 (15th November 2007)

Similar Threads

  1. Access to QSqlTableModel::isDirty Question.
    By patrik08 in forum Qt Programming
    Replies: 3
    Last Post: 12th April 2007, 17:49
  2. Replies: 1
    Last Post: 15th March 2007, 20:45
  3. Question regarding how to paint after zoom.
    By JonathanForQT4 in forum Qt Programming
    Replies: 2
    Last Post: 26th January 2007, 15:34
  4. QThread exit()/quit() question
    By TheKedge in forum Qt Programming
    Replies: 1
    Last Post: 28th August 2006, 14:38

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.