Once upon a time, the Qt people joked about switching Qt to snake_case in one of the April Fools posts.

But even if it was a joke, it did trigger me and Vishesh to talk (argue?) about it during one of aKademies.

One of the strange things I’ve noticed is that when I’m writing code that is Qt-based, I tend to use camelCase most of the time, but at the same time (in the same project) I tend to use snake_case when I’m creating generic functions. For example, a for-each algorithm that works on associative containers would be called for_each_assoc instead of forEachAssoc. This is the place where Vishesh did not agree with me.

You might ask me why I’m bringing this up now, quite a few years after the discussion.

I’ve been digging through Qt code, and I’ve encountered this:

inline QModelIndex create_index(
        int row, int column,
        QHash<QModelIndex, Mapping*>::const_iterator it) const
{
    return q_func()->createIndex(row, column, *it);
}

void _q_sourceDataChanged(const QModelIndex &source_top_left,
                          const QModelIndex &source_bottom_right,
                          const QVector<int> &roles);

void _q_sourceHeaderDataChanged(
        Qt::Orientation orientation, int start, int end);

void _q_sourceLayoutAboutToBeChanged(
        const QList<QPersistentModelIndex> &sourceParents,
        QAbstractItemModel::LayoutChangeHint hint);
void _q_sourceLayoutChanged(
        const QList<QPersistentModelIndex> &sourceParents,
        QAbstractItemModel::LayoutChangeHint hint);

void _q_sourceRowsAboutToBeInserted(const QModelIndex &source_parent,
                                    int start, int end);
void _q_sourceRowsInserted(const QModelIndex &source_parent,
                           int start, int end);

I’d say that Qt is a true framework for the new age of political correctness – it does not discriminate against any of the naming styles. :)

p.s. I’ve posted this just for fun, please do not post comments about which naming convention is better etc. No reason to start a flamewar here.