Close QMessageBox which has WindowStaysOnTopHint flag set



  • Hi,

    I am using a touchscreen on a Beaglebone and I find that I have to set the WindowStaysOnTopHint flag, otherwise push buttons on the screen seem to require two taps to activate them.

    So, I have a messagebox as shown below and the problem is that it doesn't close when the OK or Cancel buttons are pressed when the WindowStaysOnTopHint flag is set. I've tried close(), hide() and done() but they are not closing the messagebox for me.

    How do I get around this? Please point me to solutions.

    Regards,
    James

            QMessageBox msgBox(QMessageBox::Warning,
                               tr("My Application"),
                               tr("No Sync Detected!\n" "Proceed?"),
                               0, this,
                               Qt::FramelessWindowHint
                               );
    
            msgBox.setWindowFlags(Qt::WindowStaysOnTopHint);
            msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
            msgBox.setDefaultButton(QMessageBox::Ok);
            int ret = msgBox.exec();    
    
            msgBox.close();
            msgBox.hide();
            msgBox.done(0);
    
    
            switch (ret)
            {
                case QMessageBox::Ok:
                    qDebug() << "OK Pressed!";
                    StatusFlags.SYNC_OVERRIDE = 1;
                    ProceedToPulseScreen();
                    break;
                case QMessageBox::Cancel:
                default:
                    qDebug() << "Another Button Pressed!";
                    break;
            }
    
    

  • Qt Champions 2016

    Hi
    I cannot reproduce this on either windows 10 or linux (mint)
    so maybe its related to the windows manager you are using ?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.