Results 1 to 9 of 9

Thread: QVector issue going out of bounds

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2014
    Posts
    13
    Thanks
    1
    Qt products
    Qt5

    Default Re: QVector issue going out of bounds

    Quote Originally Posted by jthomps View Post
    See my edited post above.
    That was exactly it, I know why it just started happening now too. I always had it set to 15 x 15 so the height would always be equal with width so there would be no overflow.

    Thanks so much!

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QVector issue going out of bounds

    Maybe a stupid question, but the goal seems to be to call setCellValue() on all vector elements.
    Why not just iterate over the vector's length?

    Cheers,
    _

  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QVector issue going out of bounds

    Or just call QVector::fill()

  4. #4
    Join Date
    Jun 2014
    Posts
    13
    Thanks
    1
    Qt products
    Qt5

    Default Re: QVector issue going out of bounds

    Quote Originally Posted by anda_skoa View Post
    Maybe a stupid question, but the goal seems to be to call setCellValue() on all vector elements.
    Why not just iterate over the vector's length?

    Cheers,
    _

    Fair point to make. I'm not the most aware of the vector class or anything in the STL to be honest, I like it but the quick look I did on the doc of it on the Qt site I didn't see that.

    I appreciate your recommendation!

  5. #5
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QVector issue going out of bounds

    Quote Originally Posted by bnosam View Post
    Fair point to make. I'm not the most aware of the vector class or anything in the STL to be honest
    Vectors are like arrays, their elements can be accessed using the index operator []. But in contrast to arrays, they also know about their size.

    Quote Originally Posted by bnosam View Post
    I like it but the quick look I did on the doc of it on the Qt site I didn't see that
    QVector::count(), QVector::length() and QVector::size() are basically all equivalent getters for the number of elements in the vector.

    Cheers,
    _

Similar Threads

  1. sort a Qvector based on another Qvector
    By OzQTNoob in forum Qt Programming
    Replies: 2
    Last Post: 16th February 2012, 06:39
  2. Replies: 5
    Last Post: 2nd September 2011, 23:11
  3. Replies: 1
    Last Post: 5th February 2011, 03:04
  4. Out of bounds Qlist
    By seink in forum Newbie
    Replies: 2
    Last Post: 22nd November 2010, 15:31
  5. Help with out of bounds message
    By aarelovich in forum Qt Programming
    Replies: 15
    Last Post: 20th February 2009, 10:44

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.