Skip to content
QtWS25 Last Chance
  • Interpreted QML nomenclature

    Unsolved QML and Qt Quick qml javascript engine identifiers
    2
    0 Votes
    2 Posts
    503 Views
    fcarneyF
    Use longer names that are descriptive: this_pointer_to_object I would avoid leading underscore outside of any QML use cases. I think QML uses them in places that are considered private. Not 100% sure on that. I would also not use leading underscore in C++ at all. C++ specifically reserves them for special cases. In my QML naming I do this: ListView { id: scanned_items_listview delegate: Item { id: scanned_items_listview_delegate } } Now for variables in javascript it is somewhat less critical because the names only exist in the script itself (except outside resources). In that case I would avoid any and all reserved symbols that javascript uses (even for the latest version of JS). That way if the v8 engine gets updated to a newer JS version then you won't conflict with those newer symbols. For JS names being more descriptive is far less likely for naming collisions. I also avoid simple words like "object". If I need a quick object var I just do: var obj. But if I need to differentiate I will do nobj (new object). Again, this is because the scope of the variables in the JS is much smaller than the scope of a QML Item for instance.