Results 1 to 2 of 2

Thread: typedefs and Q_REGISTER_METATYPE

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

    Question typedefs and Q_REGISTER_METATYPE

    Hello,

    i'm working on a large project and i would like to be able to do as follows:
    Qt Code:
    1. typedef qreal Ratio;
    2. typedef qreal PositiveRatio;
    3. typedef qreal NegativeRatio;
    4. Q_DECLARE_METATYPE(Ratio);
    5. Q_DECLARE_METATYPE(PositiveRatio);
    6. Q_DECLARE_METATYPE(NegativeRatio);
    To copy to clipboard, switch view to plain text mode 
    However, the compiler doesn't like it, and only accepts to register the first one.

    My question is, how can i register metatypes based on the same underlying type as different types? What would be the trick if any?

    Thanks,
    Pierre.

    [edit:] The goal is to provide different edition widgets, like that, in my editors factory:
    Qt Code:
    1. /* ... */
    2. else if (t==qMetaTypeId<Ratio>() || t==qMetaTypeId<PositiveRatio>() || t==qMetaTypeId<NegativeRatio>()) {
    3. QDoubleSpinBox *spnBx = new QDoubleSpinBox(p);
    4. spnBx->setRange(t==qMetaTypeId<PositiveRatio>() ? 0.0 : -1.0, t==qMetaTypeId<NegativeRatio>() ? 0.0 : 1.0);
    5. spnBx->setSingleStep (.05);
    6. return spnBx;
    7. }
    8. /* ... */
    To copy to clipboard, switch view to plain text mode 
    [/edit]

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

    Default Re: typedefs and Q_REGISTER_METATYPE

    For those interested, i have found a good solution to this problem. It will be soon online because i have posted it to qt-interest mailing list.

Similar Threads

  1. How to specify my own global typedefs
    By Gert van Kruiningen in forum Qt Programming
    Replies: 7
    Last Post: 20th January 2011, 06:11

Tags for this Thread

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.