I use static open variables of type QMap. I fill with the help of a static function that returns a QMap.

code:

// *.h ... public: static QMap<uchar, QString> bDict; private: static QMap<uchar, QString> createMapDictionaryB(); ... ////////////////////////////////////// // *.cpp ... QMap<uchar, QString> ArrayNC::createMapDictionaryB() { QMap<uchar, QString> map; map[1] = "Значение 1"; map[3] = "Значение 2"; map[4] = "Значение 3"; ... return map; } 

When compiling an error

  • error: variable 'QMap bDict' has initializer but incomplete type

  • error: invalid use of incomplete type 'struct QMap'

  • error: return type 'struct QMap' is incomplete

Closed due to the fact that off-topic participants αλεχολυτ , Harry , Nicolas Chabanovsky 27 Dec '16 at 6:50 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reasons:

  • "The question is caused by a problem that is no longer reproduced or typed . Although similar questions may be relevant on this site, solving this question is unlikely to help future visitors. You can usually avoid similar questions by writing and researching a minimum program to reproduce the problem before publishing the question. " - Nicolas Chabanovsky
  • “Questions asking for help with debugging (“ why does this code not work? ”) Should include the desired behavior, a specific problem or error, and a minimum code for playing it right in the question . Questions without an explicit description of the problem are useless for other visitors. See How to create minimal, self-sufficient and reproducible example . " - αλεχολυτ, Harry
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • 2
    forgotten #include <QMap> in the hider? - Sublihim
  • Try a minimal reproducible example . - αλεχολυτ
  • Really) Thank you. Happens) - Andrei Maslov

2 answers 2

Forgot #include in the header. that's all)

    No definition for bDict in .cpp file.

     QMap<uchar, QString> bDict ИМЯ_КЛАССА::bDict; 
    • Did not help. error: aggregate 'QMap <unsigned char, QString> ArrayNC :: bDict' has incomplete type and cannot be defined - Andrei Maslov