'QDialog not shown over full screen app on MACOS

I implemented QDialog and want to show it as notification on top of all windows on different platforms (Windows, Linux, MAC).

My class definition:


class Notification : public QDialog
{
  Q_OBJECT
public:
  explicit Notification(QWidget* parent = nullptr);
}

And the implementation:


Notification::Notification(QWidget* parent) :
QDialog(parent),
ui(new Ui::Notification)
{
  ui->setupUI(this);
  setWindowFlags(Qt::Dialog | Qt::WindowStaysOnTopHint | Qt::WindowSystemMenuHint | Qt::FramelessWindowHint);
}

And usage of the class:


auto* notification = new Notification();
notification->show();

It works perfectly on Windows and Linux but on MAC for some reason if some other application opened on full screen (e.g. browser) then QDialog will be shown under full screen app. I tried to specify Qt::Tool and Qt::SubWindow flags instead of Qt::Dialog but this didn't help. Also, tried to call raise after show but this didn't change anything.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source