[Qt-interest] Small problem with QMap
Benjamin Sonnemann
b.sonnemann at gmail.com
Wed Mar 11 16:16:30 CET 2009
You have to instantiate the static member somewhere.
Most probably you wnat this in your cpp file:
QMap<QString, MainMenuI *> Sample::items;
just put it on the top if you want the default constructor.
Benjamin Sonnemann
On Wed, Mar 11, 2009 at 4:11 PM, Juan D Guzman <lostinthecode at googlemail.com
> wrote:
> Ok so I am still trying to learn the ropes in C++ coming from a C#
> background. I have the following code
>
> class Sample
>
> {
>
> public:
>
> Sample()
>
> {
>
> }
>
> ~Sample()
>
> {
>
> }
>
> static void addItem(QString key, MainMenuI *iMenu);
>
> private:
>
> static QMap<QString, MainMenuI *> items;
>
> };
>
>
> and in my cpp file i have the following
>
>
> void Sample::addItem(QString key, MainMenuI *iMenu)
> {
> items.insert(key, iMenu);
>
> }
>
>
> when i try to compile though i get the following error:
>
>
> sample.obj:-1: error: unresolved external symbol "private: static class
> QMap<class QString,class MainMenuI *> Sample::items"
> (?items at Sample@@0V?$QMap at VQString@@PAVMainMenuI@@@@A)
>
>
> any ideas?
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090311/d8701d97/attachment.html
More information about the Qt-interest-old
mailing list