相关疑难解决方法(0)

如何在Qt中为QMainWindow切换"always on top"而不会引起闪烁或闪烁?

void MainWindow::on_actionAlways_on_Top_triggered(bool checked)
{
    Qt::WindowFlags flags = this->windowFlags();
    if (checked)
    {
        this->setWindowFlags(flags | Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint);
        this->show();
    }
    else
    {
        this->setWindowFlags(flags ^ (Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint));
        this->show();
    }
}
Run Code Online (Sandbox Code Playgroud)

上面的解决方案有效,但因为setWindowFlags隐藏了窗口,所以需要重新显示它,当然看起来并不优雅.那么如何在没有"闪烁"副作用的情况下为QMainWindow切换"永远在线"?

c++ qt window-managers

22
推荐指数
2
解决办法
2万
查看次数

标签 统计

c++ ×1

qt ×1

window-managers ×1