Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to use QMapIterator with typedef'd QMultiMap [solved]

How to use QMapIterator with typedef'd QMultiMap [solved]

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 769 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kloveridge
    wrote on last edited by
    #1

    I use always use typedef to setup any STL type funcitonality (including QMap, QVector, etc..)

    So for example, I have this:

    @typedef QMultiMap<float, int>DistanceSorter;

    // To use this, I now can do this:

    DistanceSorter s;
    s[1.0] = 0;
    s[50.0] = 1;
    s[25] = 2;
    @

    I have used this convention for many years. But I need to do a reverse iterator through my list and I can't figure out how to do this.

    I've tried this:

    @

    DistanceSorter pset;

    pset[2.0] = 0;
    pset[1] = 1;
    pset[.5] = 3;

    QMapIterator<DistanceSorter> it<pset>;
    it.toBack();
    while( it.hasPrevious() ) {
    it.previous();
    ParticleObj *p = m_particles[it.value()];
    p->generatePoly(m_pVtxStream+idx++);
    }@

    But QMapIterator doesn't like this syntax. How do I use QMapIterator in this situation?

    1 Reply Last reply
    0
    • K Offline
      K Offline
      kloveridge
      wrote on last edited by
      #2

      This worked:
      @
      DistanceSorter pset;

      pset[2.0] = 0;
      pset[1] = 1;
      pset[.5] = 3;

      QMapIterator<float, int> it(pset);
      it.toBack();
      while( it.hasPrevious() ) {
      it.previous();
      ParticleObj *p = m_particles[it.value()];
      p->generatePoly(m_pVtxStream+idx++);
      }
      @

      I had two problems. One: I can't use my typdef argument in the <> portion of the syntax. And I put Brackets after the iterator (supposed to be it(pset) not it<pset>).

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved