Planned maintenance has been done but it did not solve the problem. So work will continue on this and a new time for trying updates will be announced asap.

QSplashScreen - Focus lost



  • I have always started my application with a splash screen and clicking on the splash screen closed it normally and the main window was left on show.

    Recently clicking on the splash screen leaves the main window behind whatever window was previously on top.

    I am looking for a way to make sure my main window is on top when the splash screen is closed. If I wait for the splash screen to close on its timer this is the case.

    Thanks



  • This post is deleted!

  • Lifetime Qt Champion

    Hi,

    What version of Qt ?
    On what platform ?
    Can you provide a minimal compile example that reproduce that behaviour ?



  • Sorry for the delay answering.

    Windows QT5.12.

    If I run this application and wait 5s the splash screen that was on top closes and my dialog is visible and on top. If I instead click on the splash screen my dialog is one layer behind whichever task was previously active. In this case Qt Creator.

    For a few years it did not have this behaviour but it started recently. Sorry I cant be specific as to which version caused the issue.

    #include "dialog.h"
    #include <QApplication>
    #include <QPixmap>
    #include <QSplashScreen>
    #include <QTimer>

    int main(int argc, char *argv[])
    {
    QApplication a(argc, argv);

    QPixmap pixmap;
    pixmap.load(":/Images/xxxxxxxxSplashSmall.bmp");
    
    QSplashScreen *splash = new QSplashScreen;
    splash->setPixmap(pixmap);
    
    Dialog w;
    w.show();
    
    splash->show();
    
    // Kill the splash screen after 5s
    QTimer::singleShot(5000, splash, SLOT(close()));
    
    return a.exec();
    

    }

    Thanks

    Brian


  • Lifetime Qt Champion

    What is Dialog ?



  • Hi,

    I just started from a bare bones application as a test program.

    dialog.h
    #ifndef DIALOG_H
    #define DIALOG_H

    #include <QDialog>

    namespace Ui {
    class Dialog;
    }

    class Dialog : public QDialog
    {
    Q_OBJECT

    public:
    explicit Dialog(QWidget *parent = nullptr);
    ~Dialog();

    private:
    Ui::Dialog *ui;
    };

    #endif // DIALOG_H

    dialog.cpp
    #include "dialog.h"
    #include "ui_dialog.h"

    Dialog::Dialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::Dialog)
    {
    ui->setupUi(this);
    }

    Dialog::~Dialog()
    {
    delete ui;
    }


  • Lifetime Qt Champion

    Tested on macOS but it's working fine...

    Can you test with the 5.13 preview ?


Log in to reply