OK first, Cancel second, or vice-versa?

I just noticed that I had been trying to make a new brush preset and at the very end had hastily clicked on Cancel instead of Save in the dialog box. This happened twice in a row, and I started to think about why I’m clicking Cancel reflexively. I started to check the various dialog boxes in Krita and elsewhere and I also found this article on UI that discusses which should come first - OK or Cancel. Anyway, I don’t have a strong opinion but I do think it has to be consistent in every application. I was just wondering if there’s any conscious attempt by the Krita dev team to keep things consistent. Anyway, below are a couple of examples where Cancel is on the left and then on the right.

Usually for OK/Cancel buttons we use Qt’s buttons, and I would guess Save is too, and then the entity that decides on the order is Qt, depending on your language. The worst mess comes when the Qt-defined buttons are mixed with custom buttons with custom text (because Qt doesn’t know where to put them, so puts them either on the left or on the right of all non-custom buttons), and then the order gets messed up, I guess.

I checked the code of the first dialog and it seems like someone added those buttons in a custom way instead of using the normal dialog buttons, which means the order is set by the programmer and not by Qt, which might explain the issue. File Layer on the other hand uses normal dialog buttons, so the order is decided by Qt.

It also depends on the platform – for instance Gnome vs Plasma.

On Windows 10, the New image window has “Create”, “Cancel”, in that order in plain simple font.
On Linux (Debian, MATE), the order is “Cancel”, “Create”.
On the small number of times I use Windows, I often press “Cancel” because I’m used to pressing the one the closest to the right edge.
On Linux, the ‘Cancel’ button also has a large red circle on it which gives a definite ‘stop’ vibe to it.

I think this is about the operating system convention or design guidelines.