diff --git a/src/libs/vmisc/compatibility.h b/src/libs/vmisc/compatibility.h index 3c8ca605d..f7fe01ad6 100644 --- a/src/libs/vmisc/compatibility.h +++ b/src/libs/vmisc/compatibility.h @@ -493,4 +493,21 @@ inline void RemoveLast(QString &str) #endif } +//--------------------------------------------------------------------------------------------------------------------- +inline void SetWindowFlag(QWidget *widget, Qt::WindowType flag, bool on = true) +{ +#if QT_VERSION >= QT_VERSION_CHECK(5, 9, 0) + widget->setWindowFlag(flag, on); +#else + if (on) + { + widget->setWindowFlags(widget->windowFlags() | flag); + } + else + { + widget->setWindowFlags(widget->windowFlags() & ~flag); + } +#endif +} + #endif // COMPATIBILITY_H diff --git a/src/libs/vwidgets/vabstractmainwindow.cpp b/src/libs/vwidgets/vabstractmainwindow.cpp index 12fe9f5c0..f628bf6f7 100644 --- a/src/libs/vwidgets/vabstractmainwindow.cpp +++ b/src/libs/vwidgets/vabstractmainwindow.cpp @@ -414,7 +414,7 @@ void VAbstractMainWindow::ExportDataToCSV() //--------------------------------------------------------------------------------------------------------------------- void VAbstractMainWindow::AlwaysOnTop(bool state) { - setWindowFlag(Qt::WindowStaysOnTopHint, state); + SetWindowFlag(this, Qt::WindowStaysOnTopHint, state); destroy(); create(); setVisible(true);