Results 1 to 6 of 6

Thread: QVector push_back error

  1. #1
    Join Date
    Feb 2014
    Posts
    7
    Thanks
    1
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default QVector push_back error

    Hello,

    I have a class that has QVector<QPoint> cameraPoints (private) vector. I try to push back this vector in a method of this class, but program unexpectedly finishes.

    when i define a qvector inside of method, it works well.

    How can i use push_back on private vector?

  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 push_back error

    There is not enough information on the problem.

    The operation should succeed on the private member vector as well.

    Check or post the backtrace of the crash.

    Cheers,
    _

  3. #3
    Join Date
    Feb 2014
    Posts
    7
    Thanks
    1
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: QVector push_back error

    Qt Code:
    1. void Route::SetCameraPositions(QVector<QPoint> *cam)
    2. {
    3. QVector<QPoint> bla;
    4. QPoint t;
    5. int x,y;
    6. for(int i=0; i<cam->size(); i++) {
    7. x = cam->at(i).x();
    8. y = cam->at(i).y();
    9. t.setX(x);
    10. t.setY(y);
    11. bla.push_back(t) //Works
    12. cameraPoints.push_back(t); //Doesn't work
    13. }
    14. }
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. private:
    2. QVector<QPoint> cameraPoints;
    To copy to clipboard, switch view to plain text mode 

  4. #4
    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 push_back error

    Should I repeat my previous comment?

    Cheers,
    _

  5. #5
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QVector push_back error

    Maybe the object on which you are trying to call this method is invalid (empty or invalid pointer). Show us relevant code or crash backtrace.

  6. #6
    Join Date
    Feb 2014
    Posts
    7
    Thanks
    1
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: QVector push_back error

    Qt Code:
    1. ==3024==
    2. ==3024== Process terminating with default action of signal 11 (SIGSEGV)
    3. ==3024== General Protection Fault
    4. ==3024== at 0x410CA5: QBasicAtomicInt::operator!=(int) const (qbasicatomic.h:75)
    5. ==3024== by 0x417AEA: QVector<QPoint>::append(QPoint const&) (qvector.h:575)
    6. ==3024== by 0x4171C2: QVector<QPoint>::push_back(QPoint const&) (qvector.h:281)
    7. ==3024== by 0x420DF0: Route::SetCameraPositions(QVector<QPoint>*) (cRoute.cpp:46)
    8. ==3024== by 0x4107DA: MainWindow::SetCameraLocations() (mainwindow.cpp:678)
    9. ==3024== by 0x40C577: MainWindow::SetupModel() (mainwindow.cpp:141)
    10. ==3024== by 0x40B6CB: MainWindow::MainWindow(QWidget*) (mainwindow.cpp:48)
    11. ==3024== by 0x40B3BF: main (main.cpp:18)
    12. ==3024==
    13. ==3024== Events : Ir
    14. ==3024== Collected : 172003489
    15. ==3024==
    16. ==3024== I refs: 172,003,489
    17. ** Process crashed **
    To copy to clipboard, switch view to plain text mode 


    EDIT: I've solved problem. It's in mainwindow file, not in the code i wrote here.
    Last edited by Eleasar; 17th April 2014 at 10:22.

Similar Threads

  1. [SOLVED]Weird compile error QObject, QVector
    By Alir3z4 in forum Qt Programming
    Replies: 2
    Last Post: 30th January 2012, 17:07
  2. 0xc0000005 error when using qVector
    By przemo in forum Newbie
    Replies: 5
    Last Post: 9th December 2010, 15:02
  3. Replies: 1
    Last Post: 3rd December 2009, 11:17
  4. QVector.push_back problem...
    By luche in forum Newbie
    Replies: 2
    Last Post: 11th January 2009, 03:22
  5. Replies: 1
    Last Post: 25th October 2008, 20:18

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.