Jan
Jan

Reputation: 1084

QT showstatus tip is shown only after mouse leave the window and return

I have a mainwindow and I'm trying to show in statusarea message when user is trying open file that don't exist.

void MainWindow::onOpenClicked(){
    if(QFile(ui->lineEditCapture->text()).exists()){
        // allow opening for analyze
    }else{
        setStatusTip("Can't open file, check if the file name is correct");
    }
}

The problem is that the statustip is shown only after the mouse pointer leaves the window and return.

Also when I do

setStatusTip("Can't open file, check if the file name is correct");

in constructor then the statustip is shown right away.

What could be wrong?

EDIT: It looks like if I do setStatusTip in slot then it's not working as it should, however if the setStatusTip is in normal method then it works as expected.

Upvotes: 1

Views: 1225

Answers (1)

pnezis
pnezis

Reputation: 12331

Use the showMessage function instead of the setStatusTip. This way you can control how long the message will be displayed:

If timeout is 0 (default), the message remains displayed until the clearMessage() slot is called or until the showMessage() slot is called again to change the message.

if (statusBar())
    statusBar()->showMessage("Can't open file, check if the file name is correct");

Upvotes: 1

Related Questions