O'Reilly logo

Qt 5 Projects by Marco Piccolino

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

And (then) the grocery items are ordered by name, ascending

In this last step, we are checking that the grocery items are returned in ascending order by their name. This seemingly simple statement actually tells us a bit more about what we should include in our groceryItems entity:

  • A method that checks whether the grocery items are ordered by name in ascending order
  • A field for each grocery item that defines its name (which could just be a string)
  • A definition of ascending order for the name field

For now, we just need to name the first method. Let's call it isSortedBy:

QVERIFY(groceryItems->isSortedBy("name","ASC"));

In the method implementation, we will be able to leverage algorithms and iterators provided by either Qt or some other library ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required