lgbo
lgbo

Reputation: 221

QWidget::showMinimized() doesn't work

On Ubuntu 13.04, if using QWidget::showMinimized() to minimize a window, I found that after restoring it by clicking the app icon the system taskbar, recalling the QWidget::showMinimized() cannot work.

connect(minimumBtn,SIGNAL(clicked()),this,SLOT(minimumWin()));
minimumWin(){
   showMinimized();
}

showMinimized() in minimumWin() doesn't work anymore if it has been called before (even the window is showed).

Upvotes: 3

Views: 3293

Answers (2)

Chandler.Bing
Chandler.Bing

Reputation: 11

I've met this problem, but I didn't solve it completely

In ubuntu system, you can use this function in your QWidget class constructor:

this->setWindowFlags(Qt::Window|Qt::FramelessWindowHint||Qt::WindowMinimizeButtonHint);

then the showMinimized() is valid to use (there is no frame and a minimize button when code running, if you have, then you're with me).

But it's only valid in ubuntu system, and this method is invalid in my company's customized (like ubuntu) operate system. I don't know why.

Upvotes: 1

user362638
user362638

Reputation:

I can reproduce this with Linux Mint and Qt 5.1. It is most probably a bug in Qt. I found that if you call showNormal() right after showMinimized(), the window minimizes and after it is restored from the taskbar, it is possible to minimize the window again. For example:

void MainWindow::on_pushButton_clicked()
{
    showMinimized();
    showNormal();
}

Upvotes: 3

Related Questions