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.

Qt missing application's icon in Windows' bottom bar



  • Welcome, I have a question about Qt's windows operations. I have a simple app which contains 2 windows:

    MainWindow - includes push button, can't be resizeable,
    AdminWindow - includes label, can be resizeable.
    When I click push button, it should open AdminWindow and hide MainWindow. I made the app and it seems to work but when I open the AdminWindow, the application icon which is located in windows's bottom bar is missing. How can I fix it?

    Icon is showed in bottom bar:
    MainWindow

    Icon isn't showed in bottom bar:
    AdminWindow

    mainwindow.h

    #ifndef MAINWINDOW_H
    #define MAINWINDOW_H
    
    #include <QMainWindow>
    #include "adminwindow.h"
    
    namespace Ui {
    class MainWindow;
    }
    
    class MainWindow : public QMainWindow
    {
        Q_OBJECT
    
    public:
        explicit MainWindow(QWidget *parent = 0);
        ~MainWindow();
    
    private slots:
        void on_pushButtonOpenAdmin_clicked();
    
    private:
        Ui::MainWindow *ui;
        AdminWindow *adminWindow;
    };
    
    #endif // MAINWINDOW_H
    

    mainwindow.cpp

    #include "mainwindow.h"
    #include "ui_mainwindow.h"
    
    MainWindow::MainWindow(QWidget *parent) :
        QMainWindow(parent),
        ui(new Ui::MainWindow)
    {
        ui->setupUi(this);
    }
    
    MainWindow::~MainWindow()
    {
        delete ui;
    }
    
    // hides MainWindow and show AdminWindow
    void MainWindow::on_pushButtonOpenAdmin_clicked()
    {
        hide();
        adminWindow = new AdminWindow(this);
        adminWindow->show();
    }
    

    adminwindow.h

    #ifndef ADMINWINDOW_H
    #define ADMINWINDOW_H
    
    #include <QMainWindow>
    
    namespace Ui {
    class AdminWindow;
    }
    
    class AdminWindow : public QMainWindow
    {
        Q_OBJECT
    
    public:
        explicit AdminWindow(QWidget *parent = 0);
        ~AdminWindow();
    
    private:
        Ui::AdminWindow *ui;
    };
    
    #endif // ADMINWINDOW_H
    

    adminwindow.cpp

    #include "adminwindow.h"
    #include "ui_adminwindow.h"
    
    AdminWindow::AdminWindow(QWidget *parent) :
        QMainWindow(parent),
        ui(new Ui::AdminWindow)
    {
        ui->setupUi(this);
    }
    
    AdminWindow::~AdminWindow()
    {
        delete ui;
    }
    

  • Qt Champions 2017

    Try not passing this as parent while creating adminwindow



  • @dheerendra Yes, it works! Thank you very much, you're great.


  • Qt Champions 2017

    Move the Qn to solved state. This helps others as well


Log in to reply