QList<QPoint*> DrawingWidget::getCloseLinesById(int m_x, int m_y) {
QList<QPoint*> lines;
// HERE I APPEND ABOUT 5 ITEMS
return lines;
}
The appending works here. It only gives me a few warnings, but it still compiles. The warning is.
taking address of temporary
But this
void DrawingWidget::mouseMoveEvent(QMouseEvent *event) {
if(m_mainWindow->getSelectedTool() == MainWindow::moveVertexTool) {
m_x = event->x();
m_y = event->y();
QList<QPoint*> points = getCloseLinesById(event->x(), event->y());
for(int i = 0; i < points.size(); i++) {
*points[i]->setX(event->x()); //error on this line
*points[i]->setY(event->y()); // error on this line
}
update();
}
}
}
result in these errors:
void value not ignored as it ought to be
void value not ignored as it ought to be
So it gives the same error for both lines.
This code should basically move my lines when I move my mouse.
How can I fix this problem?
You didn’t state what exactly is your question. But you are using extra
*in your errored lines:Also, you didn’t show how you append to the list. My guess is the warning is from you assigning addresses of some computed QPoints. It will crash even if you get it compiled. Just use
QList<QPoint>. It’s not that heavy.