My problem was caused because I wasn't setting the window flags correctly (didn't add to the current flags when I wanted to set a particular flag).

My corrected code is:

Qt Code:
  1. Qt::WindowFlags flags=windowFlags();
  2. flags^=Qt::WindowMaximizeButtonHint;
  3. setWindowFlags(flags);
To copy to clipboard, switch view to plain text mode