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. Need Help - passing 'const KanaData' as 'this' argument of 'int KanaData::KanaVowelCount(int)' discards qualifiers
Forum Updated to NodeBB v4.3 + New Features

Need Help - passing 'const KanaData' as 'this' argument of 'int KanaData::KanaVowelCount(int)' discards qualifiers

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 2.3k 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.
  • W Offline
    W Offline
    wiseguy12851
    wrote on last edited by
    #1

    I'm writing a flash-card like program to teach the Japanese Kana Alphabet but I can't get past this error. I thought maybe it was Qt Creator since I've had similar problems before but clearing the project and rebuilding it didn't fix it this time.

    This is the error message

    kanamodel.cpp:16: error: passing 'const KanaData' as 'this' argument of 'int KanaData::KanaVowelCount(int)' discards qualifiers

    I have scoured the internet and Qt Help but am lost - there is nothing constant, I am using QMap in one function but I'm not using .at() or .value(), I'm using the Square-Brackets "[]". I've checked the functions and none of them return constant values. I've even tried to call the function several different ways and all produce the exact same error message.

    These are the function calls:
    @int KanaModel::columnCount(const QModelIndex& parent) const
    {
    return modelData.KanaVowelCount(KanaSet_Hiragana); // KanaSet_Hiragana is enum
    }@

    @int KanaData::KanaVowelCount(int kSet)
    {
    if(!KanaSetExists(kSet)) return 0;
    return data[kSet].size();
    }@

    @bool KanaData::KanaSetExists(int kSet)
    {
    if(data.contains(kSet)) return true;
    return false;
    }@

    Thanks in advance!

    1 Reply Last reply
    0
    • W Offline
      W Offline
      wiseguy12851
      wrote on last edited by
      #2

      I figured it out. The problem was right in front of me - the Column Count function was constant but my function wasn't - making my function constant fixed all the relevant errors to this post.

      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