Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    QListIterator constructor parameter conversion issue

    General and Desktop
    3
    6
    3253
    Loading More Posts
    • 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
      kenbot last edited by

      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 Reply Quote 0
      • D
        dangelog last edited by

        Can you paste a snippet of relevant code?

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

        1 Reply Last reply Reply Quote 0
        • K
          kenbot last edited by

          Sure, but it's not very informative.

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

          1 Reply Last reply Reply Quote 0
          • D
            dangelog last edited by

            Including the logParsers declaration? :)

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

            1 Reply Last reply Reply Quote 0
            • K
              kenbot last edited by

              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 Reply Quote 0
              • G
                giesbert last edited by

                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 Reply Quote 0
                • First post
                  Last post