Hi,

I have the following piece of code:

    QVector<int> CompatibilityInterfaceImpl::getActionIds() const
    {
        return _actions.keys().toVector();   // _actions is a QHash
    }

In Qt Creator this generates the following warning:
   allocating an unneeded temporary container [clazy-container-anti-pattern]

How can I avoid the warning in this case?

I am using Qt 5.12, so I return a QVector instead of a QList because
using the old (Qt 5) QList is discouraged. Unfortunately many Qt API's
still use QList for nearly everything, so I am faced with a difficult
choice:

  1) go back to using QList
  2) deal with warnings and/or write my own conversion functions that
are probably not very efficient

Or is there another (convenient) way to solve this that I am not aware of?
Migrating to Qt 6 is not an option right now.


Thanks,

Kevin
_______________________________________________
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest

Reply via email to