Am 04.05.2023 um 15:51 schrieb Sune Vuorela:
In few cases the implicit conversion to underlying_type is kind of important.
Especially in the cases where the api has int and is mostly used with
enums or is somehow user extendable.

Qt::ItemDataRole is one of them that comes to mind.

switch(role) {
    case Qt::UserRole+1:
    ....

I'd argue you are using role wrong. For my models I always define a DataRole enum. With that enum all my role related switch statements looks like this:

    switch (static_cast<DataRole>(role)) {
    }

Big advantage of explicitly casting the int to my DataRole: The compiler tells me if I forget to handle any of my supported roles.


Ciao
Mathias

--
Development mailing list
Development@qt-project.org
https://lists.qt-project.org/listinfo/development

Reply via email to