Results 1 to 1 of 1

Thread: QVariant custom type.

  1. #1
    Join Date
    Dec 2006
    Posts
    160
    Thanks
    33
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default QVariant custom type.

    Hello,

    - In the same namespace (RE) i have two classes called CumulativeHistogram and BlackAndWhiteConverter respectivelly.
    - Both classes herits QObject (Indirectly via abstract classes).
    - Both classes have Q_OBJECT macro.
    - After CumulativeHistogram declaration, i have "Q_DECLARE_METATYPE(RE::CumulativeHistogram)".
    - In my BlackAndWhiteConverter class, i have:
    Qt Code:
    1. Q_PROPERTY( const CumulativeHistogram* CumulativeHistogram READ cumulativeHistogram WRITE setCumulativeHistogram)
    To copy to clipboard, switch view to plain text mode 

    Now, from my main routine, i'm doing this:
    Qt Code:
    1. bwc.setProperty("CumulativeHistogram", QVariant::fromValue<CumulativeHistogram*>(&histo));
    To copy to clipboard, switch view to plain text mode 
    bwc being an instance of BlackAndWhiteConverter, histo being a CumulativeHistogram, nothing happens. Qt tries to create the property, because it thinks it doesn't exist (See bellow why).

    When setting breakpoints, the processor is going inside QMetaProperty::write, at the line:
    Qt Code:
    1. vtypeName && strcmp(typeName, vtypeName) == 0
    To copy to clipboard, switch view to plain text mode 
    it's comparing "const RE::CumulativeHistogram*" to "RE::CumulativeHistogram*"... But i can't declare my Q_PROPERTY as non-const, because it has to be.

    The very strange thing is that if i call other properties of "scalar" types on a BlackAndWhiteConverter object (It has a few of type QRgb, unsigned char, etc), it works.

    Anyone had this problem before?
    Thanks,
    Pierre.
    Last edited by hickscorp; 3rd May 2010 at 15:17.

Similar Threads

  1. Using QVariant with custom data type
    By QAlex in forum Qt Programming
    Replies: 3
    Last Post: 4th December 2009, 12:04
  2. Convert between a custom data type wrapped in a QVariant
    By darkadept in forum Qt Programming
    Replies: 2
    Last Post: 17th March 2009, 09:07
  3. QVariant custom/user type comparison
    By gri in forum Qt Programming
    Replies: 2
    Last Post: 12th August 2008, 14:36
  4. Unable to define a new type with QVariant
    By max2g in forum Qt Programming
    Replies: 3
    Last Post: 23rd February 2008, 17:55
  5. QSettings and new QVariant Type
    By baray98 in forum Qt Programming
    Replies: 7
    Last Post: 11th February 2008, 11:40

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.