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. Issue using QLatin1String as key in QHash since reinstall of Qt (and addition of new class)

Issue using QLatin1String as key in QHash since reinstall of Qt (and addition of new class)

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

    UPDATE: I resubmitted this question "here":http://qt-project.org/forums/viewthread/49109/ because I am nearly certain I have confirmed that the reinstall is NOT the issue.

    My OS hard drive crashed and I had to reinstall my OS on a new drive. Which means I had to reinstall everything else. I have been working on implementing another library into my project (irrlicht). About an hour ago I tried compiling everything again (build from scratch). This is the first several times I have tried building since I reinstalled the OS.

    For some reason I can no longer use QLatin1String as a key for the QHash template. This worked fine before. The compiler complains that QLatin1String doesn't have a default constructor (which seems to be true). If this is a problem, then why did it compile fine before? And why is their a hash function for qlatin1string in the documentation? Even if no one can answer these questions, am I supposed to be able to use QLatin1String as a key?

    I am using QLatin1String in combination with SEVERAL different classes. Here is an example of some code that worked fine before and hasn't compiled since my reinstall:
    @mObjectTables[n] = new QHash<QLatin1String, PersistentAppObject*>();@

    1 Reply Last reply
    0
    • P Offline
      P Offline
      primem0ver
      wrote on last edited by
      #2

      Ok... I think I found part of the problem. Since no specific lines are given for the error, I did not know they all dealt with one new class in particular. But the output seems to suggest it has to do with this new class (BaseModInfo which does not have a default constructor). So could this be a bug with visual studio? It is reporting that the issue is with the key... not the value type. Or should I take it for its word? Is the QLatin1String really causing this problem?

      Here is the output when the error is produced:
      @App3DFactory.cpp
      1>D:\Developing\Projects\IMT\API\3RD_PARTY\Qt\5.3.2.32\5.3\msvc2012_opengl\include\QtCore/qhash.h(706): error C2512: 'QLatin1String::QLatin1String' : no appropriate default constructor available
      1> D:\Developing\Projects\IMT\API\3RD_PARTY\Qt\5.3.2.32\5.3\msvc2012_opengl\include\QtCore/qhash.h(705) : while compiling class template member function 'const QLatin1String QHash<Key,T>::key(const T &) const'
      1> with
      1> [
      1> Key=QLatin1String,
      1> T=AppCore::BaseModInfo *
      1> ]
      1> d:\developing\projects\imt\rosweld\trunk\source\MyApp\Appcore\IAppInfoClass.h(115) : see reference to class template instantiation 'QHash<Key,T>' being compiled
      1> with
      1> [
      1> Key=QLatin1String,
      1> T=AppCore::BaseModInfo *
      1> ]@

      1 Reply Last reply
      0
      • P Offline
        P Offline
        primem0ver
        wrote on last edited by
        #3

        Ok... so I am stuck. No default constructor with the BaseModInfo* class was not the issue because I created one and it made no difference.

        I am wondering if one of my classes is causing a problem because it is the only class that uses this particular QHash Type. And that use is in inheritance.

        @class APPCORE_EXPORT InfoCollection : public QHash<QLatin1String, BaseModInfo*>@

        Is it a bad idea to inherit from a QHash? The reason I need this is because I need a QHash of a QHash and I read somewhere that this was the only way to do it... Here is the class I need to contain a QHash of a QHash:

        @class APPCORE_EXPORT ModInfoCollection : public QHash<QLatin1String, InfoCollection*>@

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          To avoid fragmenting the discussion let's close this one

          Continued "here":http://qt-project.org/forums/viewthread/49109/

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          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