1

I'm trying to undo Stay on Top of Windows settings on my app. I thought that by performing some bitwise operations, I will be able to undo the setting, but it is still showing on top of all the other windows.

void showKioskMode(){
    //if(windowFlags()&Qt::WindowStaysOnTopHint){
    if(ui->pushButton_3->text().compare("No Kiosk") == 0){
        //showNormal();
        Qt::WindowFlags flags = windowFlags();
        flags &= ~Qt::WindowStaysOnTopHint;
        setWindowFlags(flags);
        ui->pushButton_3->setText("Yes Kiosk");
    }
    else{
        //showFullScreen();
        Qt::WindowFlags flags = windowFlags();
        setWindowFlags(flags | Qt::WindowStaysOnTopHint);
        ui->pushButton_3->setText("No Kiosk");
    }
    show();
}

I've checked that the if-body is being executed, but the window is still always on top of all other windows even though they have focus.

swtdrgn
  • 1,154
  • 4
  • 17
  • 49
  • Seen this one: http://stackoverflow.com/questions/15954875/qtwindowstaysontophint-widget-is-always-active – user2672165 Sep 30 '13 at 19:14
  • @user2672165 Doesn't that describe a solution for a pop-up widget or dialog? And, doesn't it hide the widget? I just want it to be behind the other windows. – swtdrgn Sep 30 '13 at 19:33
  • 1
    You are correct about hiding. You need to use QWidget::lower(). I was just thinking in the direction that this could be related as it says "This will hide the helper widget when switching apps". It could be applied also to any other widget. E.g. popup_spec->hide() could be this->lower(). – user2672165 Sep 30 '13 at 19:41
  • I thought that (lower function) only applies to all widgets on the parent widget's stack. Does that actually apply to other external processes? I tried to make the call to lower() function via onClick slot of a button, but it didn't send the window to the back or behind the process that has focus. – swtdrgn Sep 30 '13 at 19:58
  • @swtdrgn Clearing the flag won't move the window anywhere immediately, just not make it stay on top the next time another application's window is brought to the foreground. (And no, lower() won't help here) – Frank Osterfeld Sep 30 '13 at 22:09
  • Of course I did not understand your case. – user2672165 Oct 01 '13 at 06:06
  • @Frank Osterfeld Yes, that's the behavior that I want. But removing the flag did not produce such a behavior, that is if I am removing the flag correctly. – swtdrgn Oct 01 '13 at 14:14
  • 1
    Might be a Qt bug then. – Frank Osterfeld Oct 01 '13 at 15:06

1 Answers1

0

Looks like that it is a bug. The solution can be found in the following thread:

It has a separate solution for Windows via WinAPI.

Community
  • 1
  • 1
swtdrgn
  • 1,154
  • 4
  • 17
  • 49