Ahmed Abdellatif
14th September 2018, 14:10
I have a QList<QPOintf> that has 10 element inside it, i want to copy the list in a reverse order then append it again to the list but this is done after changing the y value of QPointf. For example:
suppose our list is as follow:
m_resultPoints has the following points [(1,2),(1,3),(5,6),(7,2),(3,4),(7,9),(4,5),(2,0),(2 ,4),(4,7)];
I want it to be:
m_resultPoints should have the following points [(1,2),(1,3),(5,6),(7,2),(3,4),(7,9),(4,5),(2,0),(2 ,4),(4,7),(4,-7),(2,-4),(2,-0),(4,-5),(7,-9),(3,-4),(7,-2),(5,-6),(1,-3),(1,-2)];
So I put the list in a loop and created a QPointf dynamically using new operator and appended it to the list content. Now who take the owner ship of the points, i think it is the QList, am i right ?
I also wonder if there is another way to do this in more elegant way, thanks in advance.
Here is the code snippet that is used to do the appending and the reversing of the list points:
for (int i = 0; i < m_resultPoints->size(); ++i) {
m_resultPoints->append(*new QPointF(m_resultPoints->at(m_resultPoints->size()-i).x() , (-1*m_resultPoints->at(m_resultPoints->size()-i).y() )));
}
suppose our list is as follow:
m_resultPoints has the following points [(1,2),(1,3),(5,6),(7,2),(3,4),(7,9),(4,5),(2,0),(2 ,4),(4,7)];
I want it to be:
m_resultPoints should have the following points [(1,2),(1,3),(5,6),(7,2),(3,4),(7,9),(4,5),(2,0),(2 ,4),(4,7),(4,-7),(2,-4),(2,-0),(4,-5),(7,-9),(3,-4),(7,-2),(5,-6),(1,-3),(1,-2)];
So I put the list in a loop and created a QPointf dynamically using new operator and appended it to the list content. Now who take the owner ship of the points, i think it is the QList, am i right ?
I also wonder if there is another way to do this in more elegant way, thanks in advance.
Here is the code snippet that is used to do the appending and the reversing of the list points:
for (int i = 0; i < m_resultPoints->size(); ++i) {
m_resultPoints->append(*new QPointF(m_resultPoints->at(m_resultPoints->size()-i).x() , (-1*m_resultPoints->at(m_resultPoints->size()-i).y() )));
}