Type casting error



  • During compilation occures error on line represented below in description. Description of the error:

    ... : expected primary-expression before '>' token
    this->listOfPairs = settings->value< QList< QPair< QString, QString> > >("Users/" + name + "/KeysList");

    Where '>' token mensioned above is the last '>' token in the error message snippet.
    The variables listOfPairs and **settings have QList< QPair< QString, QString> > and QSettings * types respectively.

    Thanks in advance for any help.

    Во время компиляции программы возникает ошибка в строке представленной в описании ошибки. Где упомянутый '>'-знак - это последний '>'-знак приложенного отрывка описания ошибки.
    Переменные listOfPairs и settings имеют типы QList< QPair< QString, QString> > и QSettings * соответственно. Заранее благодарен за любую помощь.



  • Hi, settings->value() is not a template, that's why you get compiler error.

    The settings object I think can only give you a QString, then you have to split it yourself into a QPair<QString,QString> for example like this:

    QStringList sl = settings->value("Users/" + name + "/KeysList").toString().split(":");  // just guessing your separator is  :
    QPair<QString,QString> p = qMakePair(sl[0],sl[1]);
    // now you can append p to your list :-)
    


  • Yes, it works. But I found another way of that problem solving. Using of nesting returned Qvalue with qvariant_cast<QList< QPair< QString, QString> > >() also works.
    Thanks for answer.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.