Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6572945
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:04:11+00:00 2026-05-25T15:04:11+00:00

I want to iterate over a QMultiMap using QMultiMap<double, TSortable>::const_iterator it;` but the compiler

  • 0

I want to iterate over a QMultiMap using

QMultiMap<double, TSortable>::const_iterator it;`

but the compiler complains

error: expected ‘;’ before ‘it’

resulting in a

error: ‘it’ was not declared in this scope

for every usage. I tried ConstIterator, const_iterator and even the slower Iterator without any success. Is it even possible to use Q(Multi)Map with a template class? Why can’t I declare an Iterator when definition (as void*) is ok?

I use the following code (include guard omitted):

#include <QtCore/QDebug>
#include <QtCore/QMap>
#include <QtCore/QMultiMap>
#include <limits>

/** TSortable has to implement minDistance() and maxDistance() */
template<class TSortable>
class PriorityQueue {
public:

  PriorityQueue(int limitTopCount)
      : limitTopCount_(limitTopCount), actMaxLimit_(std::numeric_limits<double>::max())
  {
  }

  virtual ~PriorityQueue(){}

private:
  void updateActMaxLimit(){
    if(maxMap_.count() < limitTopCount_){
      // if there are not enogh members, there is no upper limit for insert
      actMaxLimit_ = std::numeric_limits<double>::max();
      return;
    }
    // determine new max limit

    QMultiMap<double, TSortable>::const_iterator it;
    it = maxMap_.constBegin();
    int act = 0;
    while(act!=limitTopCount_){
      ++it;// forward to kMax
    }
    actMaxLimit_ = it.key();

  }

  const int limitTopCount_;
  double actMaxLimit_;
  QMultiMap<double, TSortable> maxMap_;// key=maxDistance
};
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T15:04:12+00:00Added an answer on May 25, 2026 at 3:04 pm

    GCC gives this error before the one you quoted:

    error: need ‘typename’ before ‘QMultiMap<double, TSortable>::const_iterator’ because ‘QMultiMap<double, TSortable>’ is a dependent scope
    

    which explains the problem. Add the typename keyword:

    typename QMultiMap<double, TSortable>::const_iterator it;
    

    and it will build.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Richfaces JSF and I want to iterate over an Map<Object,Object> . I
I have an NSDictionary and want to iterate over the objects. But at the
I have a JSON list that I want to iterate over, but skip the
I am using T4 in Visual Studio 2010, and I want to iterate over
I have Map type. I want to iterate over it using struts tag library.
I want to iterate over files in a folder using powershell script;
I want to iterate over a sequence in xquery and grab 2 elements at
I want to iterate over an array of inputs that belong to certain class
I have a boost::bimap and I want to iterate over all positions to add
I have a Hashtable in Java and want to iterate over all the values

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.