First, your Qt code will not compile as posted. When the error is corrected the code compiles and runs just fine:
#include <QCoreApplication>
#include <QDebug>
int main(int argc, char **argv)
{
// Your snippet v correction
QList<QPair<int,int> > listOfPairs;
QPair<int,int> pair(1,1);
listOfPairs.insert(0,pair);
// Put more in the list
listOfPairs.append(QPair<int, int>(2, 3));
listOfPairs.append(QPair<int, int>(4, 5));
qDebug() << listOfPairs;
return 0;
}
#include <QCoreApplication>
#include <QDebug>
int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);
// Your snippet v correction
QList<QPair<int,int> > listOfPairs;
QPair<int,int> pair(1,1);
listOfPairs.insert(0,pair);
// Put more in the list
listOfPairs.append(QPair<int, int>(2, 3));
listOfPairs.append(QPair<int, int>(4, 5));
qDebug() << listOfPairs;
return 0;
}
To copy to clipboard, switch view to plain text mode
Output:
(QPair(1,1) , QPair(2,3) , QPair(4,5) )
To copy to clipboard, switch view to plain text mode
So, the thing that does not work and then "does not work again" is probably the method you are using to inspect the list, but we cannot see that.
Bookmarks