简体   繁体   中英

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); in Windows.
How can I make the same in Linux?

QApplication::alert(this); does not work for me.
KDE Desktop 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.

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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