QVector.push_back problem...
Hello to all,
i've used to be a programmer but i'ts been a long time (more than 8 years) since i've done any programming. I'm now getting back in shape by learning to program with Qt4.
Here's my problem so far with the following code:
In the header file:
Code:
QVector<QPoint> m_cheatTrajectoryPt;
Code:
m_cheatTrajectoryPt.
push_back(QPoint(qRound
(x
), height
() - 1 - qRound
(y
)));
And here is the compile error that puzzles me:
Code:
cannonfield.cpp: In member function 'QRect CannonField::shotRect() const’:
cannonfield.cpp:134: erreur: passing 'const QVector<QPoint>' as ‘this’ argument of ‘void QVector<T>::push_back(const T&) [with T = QPoint]’ discards qualifiers
Any help would be greatly appreciated!
Thanks!
Luc
Re: QVector.push_back problem...
Hi,
Quote:
Originally Posted by
luche
I'm now getting back in shape by learning to program with Qt4.
Remember that in order to be successful with Qt you need to know C++. Qt is not a programming language. :)
Quote:
cannonfield.cpp: In member function 'QRect CannonField::shotRect() const’:
cannonfield.cpp:134: erreur: passing 'const QVector<QPoint>' as ‘this’ argument of ‘void QVector<T>::push_back(const T&) [with T = QPoint]’ discards qualifiers
You are trying to modify a member variable (m_cheatTrajectoryPt) in a const method (CannonField::shortRect). A const method shouldn't change the state of an object.
Re: QVector.push_back problem...
Quote:
Originally Posted by
jpn
Hi,
Remember that in order to be successful with Qt you need to know C++. Qt is not a programming language. :)
You are trying to modify a member variable (m_cheatTrajectoryPt) in a const method (CannonField::shortRect). A const method shouldn't change the state of an object.
I'm rusty ;)
Thanks for your help :cool: