Aquarius_Girl
Aquarius_Girl

Reputation: 22906

How to display QPointF stored in a QList?

QList <QPointF> markers;
markers.append (QPointF (getLat (), getLon ()));


QList <QPointF> :: iterator i;
for (i = markers.begin(); i != markers.end(); ++i)
     std :: cout << *i << endl;

Gives me:

error: no match for 'operator<<' in 'std::cout << i.QList::iterator::operator* with T = QPointF'

Upvotes: 0

Views: 1838

Answers (3)

Dimitry Ernot
Dimitry Ernot

Reputation: 6584

A foreach loop would be simplier for that:

Q_FOREACH( QPointF p, markers ) {
    qDebug() << p;
}

Upvotes: 2

thuga
thuga

Reputation: 12901

You can use qDebug().

QList<QPointF> markers;
markers.append(getLat(), getLon());
QList<QPointF>::iterator i;
for (i = markers.begin(); i != markers.end(); ++i)
    qDebug() << *i;

Remember to include QDebug:

#include <QDebug>

Upvotes: 4

Abhishek Bansal
Abhishek Bansal

Reputation: 12715

AFAIK QPointF class by itself does not have a << overload operator. You can either re-implement it and overload the operator yourself or more simply just try to output the coordinates myPoint.x() and myPoint.y().

Upvotes: 1

Related Questions