Results 1 to 8 of 8

Thread: QVariant - storing QIcons[]

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2006
    Posts
    83

    Default Re: QVariant - storing QIcons[]

    it must be char* , .toString() is nut sufficient

  2. #2
    Join Date
    Aug 2006
    Posts
    250
    Thanks
    19
    Thanked 49 Times in 36 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QVariant - storing QIcons[]

    Have a look at QVariant::setValue.

    void QVariant::setValue ( const T & value )
    Stores a copy of value. If T is a type that QVariant doesn't support, QMetaType is used to store the value. A compile error will occur if QMetaType doesn't handle the type.
    Example:
    QVariant v;

    v.setValue(5);
    int i = v.toInt(); // i is now 5
    QString s = v.toString() // s is now "5"

    MyCustomStruct c;
    v.setValue(c);

    ...

    MyCustomStruct c2 = v.value<MyCustomStruct>();

  3. #3
    Join Date
    Aug 2006
    Posts
    83

    Default Re: QVariant - storing QIcons[]

    I tried using that but it failed.

    The code that jpn submitted works just fine for me.
    QString str = action->data().toString(); // maybe this is sufficient?
    char* ptr = qstrdup(qPrintable(str)); // if not, remember to delete

    I'm really pleased with this forum as I see that there are a lot of friendly people who are not just trying to be smart but really come with solutions. Tnx

Similar Threads

  1. QVariant types support for custom properties
    By Dusdan in forum Qt Tools
    Replies: 9
    Last Post: 11th January 2006, 09:55

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
  •  
Qt is a trademark of The Qt Company.