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. QMap/QHash: not remove and not reinsert item.

QMap/QHash: not remove and not reinsert item.

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 3.1k 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
    kunashir
    wrote on last edited by
    #1

    Hello!
    I have completed QMap/QHash.
    And I try remove or reinsert value whis a key, , which is already in Map.
    But nothing happens.
    If I try remove, function return value not equal 0, but in the debugger value remains the same.
    @
    void CListsItmes::setAttr(int row, int col, QVariant value)
    {
    if (!value.isValid())
    return;
    int i = listItem->value(row).remove(lsNameAttr.value(col)); //try remove before inserting
    listItem->value(row).insert(lsNameAttr.value(col), value);
    //work whis BD
    QUERY_COND cond;
    cond.nameAttr = "id";
    cond.sign = "=";
    cond.value = (*listItem).value(row).value(QString("id")).toString();
    datasoure.setItemAttr(cond, getName(), lsNameAttr.value(col), value);
    }
    @

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on last edited by
      #2

      And what is your problem? From that dump of variable names, we cannot get anything meaningful (we do not know your code).

      The best way to present those problems to a forum is to create a test case that demonstrates the erroneous behavior. This usually consists a small, complete, compilable program; most often less more than a main function and one or two small classes. And chances are good that you stumble over the cause of the problem during the process of preparing that test case :-)

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • K Offline
        K Offline
        kunashir
        wrote on last edited by
        #3

        Thank you!

        Your method realy work - I began to implement my problem, and understand that - function value of QList return const T.
        Change "value" to [] and all is ok.

        1 Reply Last reply
        0
        • G Offline
          G Offline
          goetz
          wrote on last edited by
          #4

          Congrats - and enjoy coding with Qt :-)

          http://www.catb.org/~esr/faqs/smart-questions.html

          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