When pressing the right Alt key in QMainWindow with the keyboard layout set to, say, Hungarian or German, the key is not properly detected as AltGr in QMainWindow's keyPressEvent() method. Instead, it is detected as the Alt key. Attached is an example that prints the key pressed when the key captured in keyPressEvent() is Alt or AltGr. Set your keyboard to be Hungarian from WIndow's "Text Services and Input" dialog (available under the "Regions and Language" dialog -> "Keyboard and Languages" tab -> "Change Keyboards..." button). From within the attached code's main window, press the right Alt key. The code will incorrectly print "Alt pressed" to the console, when it should print "AltGr pressed".
I cannot replicate this behavior in Linux (Qt 5.11.0). It appears to only affect Windows. I am using the MinGW version of Qt 5.10.1, if that helps.