简体   繁体   English

如何在Linux中运行FlashWindow?

[英]How to run FlashWindow in Linux?

I need to highlight a window in the taskbar when the process is finished. 该过程完成后,我需要在任务栏中突出显示一个窗口。

I call ::FlashWindow((HWND)winId(), false); 我叫::FlashWindow((HWND)winId(), false); in Windows. 在Windows中。
How can I make the same in Linux? 我如何在Linux中做同样的事情?

QApplication::alert(this); does not work for me. 对我不起作用。
KDE Desktop 5. KDE桌面5。


This code does not work for me. 此代码对我不起作用。

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    connect(ui->pushButton, SIGNAL(released()), this, SLOT(test()));
}

void MainWindow::test()
{
    QThread::msleep(5000);
    QApplication::alert(this);
}

But this one works. 但这是可行的。

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    QTimer *timer = new QTimer();

    QObject::connect(timer, SIGNAL(timeout()), this, SLOT(timer_alert()));
    timer->start(5000);
}

void MainWindow::timer_alert() {
    QApplication::alert(this);
}

What is the difference? 有什么区别?

There is no general method to accomplish this, because it depends on the desktop environment . 没有通用的方法可以完成此操作,因为它取决于桌面环境

There may not be a "taskbar" (or a panel) at all. 可能根本没有“任务栏”(或面板)。 In the past, there was a similar issue for browser makers, trying to support the window.getAttention() method. 过去,尝试支持window.getAttention()方法的浏览器制造商遇到了类似的问题。

Even blinking the title bar may not be so easy, since Qt does not have any control over the window decoration (borders and title), so you may need to implement this manually using Xlib. 即使Qt标题栏闪烁也不是一件容易的事,因为Qt对窗口装饰(边框和标题)没有任何控制,因此您可能需要使用Xlib手动实现。

If you want to obtain the same effect on all the target platforms, you may consider implementing a simple "blinking" effect (eg playing with the window opacity ). 如果要在所有目标平台上获得相同的效果,则可以考虑实现简单的“闪烁”效果(例如,使用窗口不透明度 )。 Beware though that window opacity is supported on X11 only if you run a compositor. 请注意,仅当您运行合成器时,X11才支持该窗口不透明度。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM