Qt Labs Forum » ModelTest

ModelTest and QVariant

(2 posts)
  • Started 1 year ago by Ralf
  • Latest reply from Benjamin Meyer

Tags:


  1. Ralf
    Ralf
    Member

    In ModelTest.cpp:325ff it reads:

    > While you can technically return a QVariant usually this is a sign of an bug in data()

    Why is this? I normally return a QVariant() for data I do not have (e.g. if an item has no tooltip or icon, I return QVariant() for Qt::ToolTipRole and Qt::DecorationRole.
    Is there something wrong or unusual about it?

    Ralf

    Posted: 1 year #
  2. Benjamin Meyer
    Benjamin Meyer
    Administrator

    That particular test is checking the data role: Qt::DisplayRole, which usually would return a QString.

    The bug that this was made to find was cases where a developer would plug a new model into a view, only to find the view wasn't displaying any text at all.

    There is nothing wrong with returning a QVariant() for the DisplayRole. Disabling this test or returning an empty QString are two ways to work around this report.

    Posted: 1 year #

RSS feed for this topic

Reply

You must log in to post.



© 2008 Nokia Corporation and/or its subsidiaries. Nokia, Qt and their respective logos are trademarks of Nokia Corporation in Finland and/or other countries worldwide.
All other trademarks are property of their respective owners.