Avoid using QByteArray::operator[] for the null terminator
While QByteArray has an implicit null terminator at the end, this is not meant to be accessible through operator[]. In Qt 5, OOB accesses return 0 (and cause a warning in later versions), but in Qt 6 it's forbidden entirely. Rewrite the code slightly to just avoid reading the null terminator altogether. For completeness, this also zeros the remaining buffer when Xlib events are used.
Also replace use of strlen with QByteArray::size().