Results 1 to 2 of 2

Thread: How to make a general purpose storage class?

  1. #1
    Join Date
    Jan 2009
    Posts
    8
    Thanks
    1

    Default How to make a general purpose storage class?

    Dear

    I am hoping to create a multi-purpose class that store thing. Does any have an idea how to implement this?

    I am thinking of using a QMap< QString key, "a non type thing pointer" > map that let me store any thing with key and later retrieve it using the key. however, the value must be of a general-non-type type like the QVariant such that I can cast it back to my type and use. But I don't know how to use Qvariant for this purpose.

    Had anyone toy around with this idea or have recommended solution? Is there a way? Is it even possible?

    thanks in advance
    khikho

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to make a general purpose storage class?

    How about just using QVariantMap? You can store any type you want in QVariant. Read about Q_DECLARE_METATYPE.

Similar Threads

  1. Compiling with Qmake/Make
    By VireX in forum Newbie
    Replies: 25
    Last Post: 22nd February 2007, 05:57

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.