UI is my main window (inherits QWidget) and the only warning I get is "Invalid parameter passed to C runtime function.".

Anyway, the problem disappeared after declaring ui on heap and initializing it with the new keyword.