Hi,
I have created a vector of structs like this:

Qt Code:
  1. struct Review {
  2. QString title;
  3. QString page;
  4. };
To copy to clipboard, switch view to plain text mode 

I filled it with data from a database; now I need to sort alphabetically by title this vector; I made a bubbleSort function:

Qt Code:
  1. void MagazineWidget::bubbleSort(QVector<Review> vector)
  2. {
  3. bool swap = true;
  4.  
  5. for(int j = 0; swap; j++)
  6. {
  7. swap = false;
  8. for(int k = vector.size()-1; k > j; k--)
  9. {
  10. if(vector.at(k).title < vector.at(k-1).title)
  11. {
  12. Review temp;
  13. temp.title = vector.at(k).title;
  14. temp.page = vector.at(k).page;
  15. vector.at(k).title = vector.at(k-1).title;
  16. vector.at(k).page = vector.at(k-1).page;
  17. vector.at(k-1).title = temp.title;
  18. vector.at(k-1).page = temp.page;
  19. swap = true;
  20. }
  21. }
  22. }
  23. }
To copy to clipboard, switch view to plain text mode 

and call it with this statement:

Qt Code:
  1. QVector<Review> reviews;
  2. // ...
  3. // Filling the vector
  4. // ...
  5. bubbleSort(reviews);
To copy to clipboard, switch view to plain text mode 

During compilation I got the following error on lines 15-18:

Qt Code:
  1. error: passing ‘const QString’ as ‘this’ argument of ‘QString& QString::operator=(const QString&)’ discards qualifiers
To copy to clipboard, switch view to plain text mode 

Thanks