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. QListIterator constructor parameter conversion issue
QtWS25 Last Chance

QListIterator constructor parameter conversion issue

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 3.5k Views
  • 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
    kenbot
    wrote on last edited by
    #1

    I have a QList<LogParser*> logParsers where LogParser is a class I defined.

    When I try to create a QListIterator<LogParser*> iterator(logParsers), the compiler complains

    'QListIterator<T>::QListIterator(const QList<T> &)' : cannot convert parameter 1 from 'QList<T>' to 'const QList<T> &'

    What am I doing wrong?

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dangelog
      wrote on last edited by
      #2

      Can you paste a snippet of relevant code?

      Software Engineer
      KDAB (UK) Ltd., a KDAB Group company

      1 Reply Last reply
      0
      • K Offline
        K Offline
        kenbot
        wrote on last edited by
        #3

        Sure, but it's not very informative.

        @QListIterator<LogParser*> iterator(logParsers);
        while(iterator.hasNext()) {
        iterator.next()->start();
        }@

        1 Reply Last reply
        0
        • D Offline
          D Offline
          dangelog
          wrote on last edited by
          #4

          Including the logParsers declaration? :)

          Software Engineer
          KDAB (UK) Ltd., a KDAB Group company

          1 Reply Last reply
          0
          • K Offline
            K Offline
            kenbot
            wrote on last edited by
            #5

            That's in the header file:
            @QList<LogParser*> logParsers;@

            and the constructor for this class has this bit to populate logParsers:
            @for(int i = 0; i < deviceCount; ++i) {
            logParsers.append(new LogParser(i));
            connect( logParsers[i], SIGNAL(deviceNotOpen()), SLOT(deviceNotOpen()));
            connect( logParsers[i], SIGNAL(setupComplete()), SLOT(startTimer()));
            }@

            1 Reply Last reply
            0
            • G Offline
              G Offline
              giesbert
              wrote on last edited by
              #6

              Hi kenbrot,

              this code perfectly compiles:

              @
              class LogParser
              {
              public:
              int i;
              int j;
              QList<int> m;
              void start() {}
              };

              int main(int argc, char argv[])
              {
              QList<LogParser
              > logParsers;

              QListIterator<LogParser*> iterator(logParsers);
              while(iterator.hasNext()) {
                   iterator.next()->start();
              }
              
              return 0;
              

              }
              @

              Perhaps LogParser is only predefined?

              Nokia Certified Qt Specialist.
              Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

              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