[Solved]How to convert QVariant to Qt::CheckState enum value?
-
I tried this but it does not work...
@
// model is a subclass of QFileSystemModel
Qt::CheckState state = static_castQt::CheckState(model->data(index, Qt::CheckStateRole));
@ -
Try this:
@
Qt::CheckState state = model->data(index, Qt::CheckStateRole).valueQt::CheckState();
@ -
Thanks ZapB... but your repsonse gave me an error
@
error: ‘qt_metatype_id’ is not a member of ‘QMetaTypeIdQt::CheckState’
@however, I tried the following and it works...
@
Qt::CheckState state = static_castQt::CheckState(model->data(index, Qt::CheckStateRole).toUInt());
@ -
Ah yes of course. Sorry for the false lead. Brain not working today.
-
You can try to cast the value to an int and store that (casting it back when reading it). Alternatively you can register the type with the Qt metatype system yourself. Check the docs:-)