[Qt-interest] QtTest data-driven approach with custom types
Andreas Pakulat
apaku at gmx.de
Fri Jul 30 12:51:18 CEST 2010
On 30.07.10 11:30:01, Kimmo Viitanen wrote:
> Hello,
>
> I wrote a test for a class of mine using QtTest. After writing the
> test I figured
> the way I was testing would be ideal for the data-driven type of testing using
> the _data() function. This will not work, however; I get an error
> telling me that
> qt_metatype_id is not a member of
> QMetaTypeId<QVector<Sub_GameUtility::Identification> >.
>
> Identification here is a class of my own. Now is this Qt's way of telling me
> that I cannot use QVector in a _data() function and FETCH() it? Or that I
> cannot use my custom type? Would I have to derive it from QObject?
Its Qt's way of telling you that you cannot transport QVector<CustomType>
through a QVariant (which is what the data-driven stuff uses behind the
scenes). What you can do is transport a QList<QVariant>, so you'll have to
wrap your objects of CustomType into a QVariant and then put that into a
list. See the QVariant api docs for the necessary steps to make custom
types known to it.
Andreas
--
Never commit yourself! Let someone else commit you.
More information about the Qt-interest-old
mailing list