Reputation: 8293
In a custom item model, I want to call data changed with some given roles.
With 2 items in the initializer-list
, it compiles just fine:
emit dataChanged(index, index, QVector<int>{ Qt::CheckStateRole, Qt::DisplayRole });
However, when I add a third item to the list it fails:
emit dataChanged(index, index, QVector<int> { Qt::CheckStateRole, Qt::DisplayRole, Qt::DecorationRole });
error C2440: '<function-style-cast>' : cannot convert from 'initializer-list' to 'QVector<int>'
2> No constructor could take the source type, or constructor overload resolution was ambiguous
It doesn't seem to matter what the roles are, any two will compile and the third will not. I'm using MSVC2013 and Qt 5.4.1. Am I doing something wrong here?
Upvotes: 3
Views: 903
Reputation: 28151
If you haven't already, I would update your VS2013 to Update 5. Especially, in Update 4 they have fixed some issues with initializer lists. Also see this QTBUG-39142
It seems like your compiler is trying to construct a QVector
object using the normal constructors. You could also verify that you have C++11 enabled and Q_COMPILER_INITIALIZER_LISTS
is defined.
Upvotes: 4