Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt missing application's icon in Windows' bottom bar
QtWS25 Last Chance

Qt missing application's icon in Windows' bottom bar

Scheduled Pinned Locked Moved Solved General and Desktop
mainwindow
4 Posts 2 Posters 1.9k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ? Offline
    ? Offline
    A Former User
    wrote on 7 Feb 2017, 14:52 last edited by
    #1

    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;
    }
    
    1 Reply Last reply
    0
    • D Offline
      D Offline
      dheerendra
      Qt Champions 2022
      wrote on 7 Feb 2017, 16:52 last edited by
      #2

      Try not passing this as parent while creating adminwindow

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      ? 1 Reply Last reply 8 Feb 2017, 11:02
      8
      • D dheerendra
        7 Feb 2017, 16:52

        Try not passing this as parent while creating adminwindow

        ? Offline
        ? Offline
        A Former User
        wrote on 8 Feb 2017, 11:02 last edited by
        #3

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

        1 Reply Last reply
        0
        • D Offline
          D Offline
          dheerendra
          Qt Champions 2022
          wrote on 8 Feb 2017, 11:31 last edited by
          #4

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

          Dheerendra
          @Community Service
          Certified Qt Specialist
          http://www.pthinks.com

          1 Reply Last reply
          6

          4/4

          8 Feb 2017, 11:31

          • Login

          • Login or register to search.
          4 out of 4
          • First post
            4/4
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved