Qt World Summit: Submit your Presentation

QListIterator constructor parameter conversion issue

  • 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?

  • Can you paste a snippet of relevant code?

  • Sure, but it's not very informative.

    @QListIterator<LogParser*> iterator(logParsers);
    while(iterator.hasNext()) {

  • Including the logParsers declaration? :)

  • 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()));

  • Hi kenbrot,

    this code perfectly compiles:

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

    int main(int argc, char argv[])
    > logParsers;

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


    Perhaps LogParser is only predefined?

Log in to reply