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. [SOLVED] QHash string error
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] QHash string error

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 2.2k Views 1 Watching
  • 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
    kalster
    wrote on last edited by
    #1

    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.

    mainwindow.h
    @#include <QHash>
    private:
    QHash<QString,QString> users;
    @

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

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

    1 Reply Last reply
    0
    • K Offline
      K Offline
      kalster
      wrote on last edited by
      #2

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

      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