Important: Please read the Qt Code of Conduct -

[SOLVED] QHash string error

  • i am trying to use QHash as strings instead of arrays as variables. for example, with arrays i need to use ...
    @userselect[100]; @
    but with QHash i can use i think...
    @userselect[stringName] @
    below is the code and the error i am getting. i am trying to use a string in the qhash but it is not working.

    @#include <QHash>
    QHash<QString,QString> users;

    @QString userselect;
    userselect = "name";
    QStringList userselect;
    users[userselect] = "test";

    error: no match for 'operator[]' in '((MainWindow*)this)->MainWindow::users[userSelect]'

  • i solved this post. i had to remove the line QStringList userselect; from the mainwindow.cpp file. sorry for this inconvenience.

Log in to reply