QT QDialog bug under metacity and a workaround

QDialog under QT 4.8 and 5.3 (I haven’t tested other versions. 5.3 was the latest) doesn’t behave well under Ubuntu 12.04 (using Unity 2D under metacity). The workaround is to trick metacity and make it believe a QDialog is a normal window.

//example inside the QDialog

I already reported the bug and the workaround to QT and I’ve put a bigger explanation on stackoverflow since Metacity/Digia/QT won’t do anything to solve it.