QWidget::setWindowFlag was introduced since Qt 5.9.

This commit is contained in:
Roman Telezhynskyi 2023-11-16 11:32:13 +02:00
parent 0225ade6fc
commit 3d0573f2a7
2 changed files with 18 additions and 1 deletions

View File

@ -493,4 +493,21 @@ inline void RemoveLast(QString &str)
#endif #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 #endif // COMPATIBILITY_H

View File

@ -414,7 +414,7 @@ void VAbstractMainWindow::ExportDataToCSV()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VAbstractMainWindow::AlwaysOnTop(bool state) void VAbstractMainWindow::AlwaysOnTop(bool state)
{ {
setWindowFlag(Qt::WindowStaysOnTopHint, state); SetWindowFlag(this, Qt::WindowStaysOnTopHint, state);
destroy(); destroy();
create(); create();
setVisible(true); setVisible(true);