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. The window in the task bar does not appear
Forum Updated to NodeBB v4.3 + New Features

The window in the task bar does not appear

Scheduled Pinned Locked Moved Unsolved General and Desktop
22 Posts 4 Posters 5.0k Views 1 Watching
  • 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.
  • M Mask
    15 Oct 2018, 06:44

    Hi, thanks for the reply.
    I mean that after making the Switch of QMainWindow the application disappears at the bottom and it is as if it were not executed and if I try to minimize it appears in a small window in the bottom left (if I have not explained, I send you a screen as soon as I go back from school).
    I'm new to programming with graphics, but with the tutorials I saw, I noticed that everyone used the QMainWindow.
    The version I use is 5.11 and I use it on Windows.

    J Offline
    J Offline
    jsulm
    Lifetime Qt Champion
    wrote on 15 Oct 2018, 07:20 last edited by
    #4

    @Mask Why don't you use QDialog for your Login instead of QMainWindow? Create QMainWindow only if log-in was successful.

    https://forum.qt.io/topic/113070/qt-code-of-conduct

    M 1 Reply Last reply 15 Oct 2018, 14:13
    2
    • J jsulm
      15 Oct 2018, 07:20

      @Mask Why don't you use QDialog for your Login instead of QMainWindow? Create QMainWindow only if log-in was successful.

      M Offline
      M Offline
      Mask
      wrote on 15 Oct 2018, 14:13 last edited by
      #5

      @jsulm said in The window in the task bar does not appear:

      @Mask Why don't you use QDialog for your Login instead of QMainWindow? Create QMainWindow only if log-in was successful.

      I've just tried, the result does not change after login does not appear in the taskbar.

      Thanks anyway.

      J 1 Reply Last reply 15 Oct 2018, 14:54
      0
      • M Mask
        15 Oct 2018, 14:13

        @jsulm said in The window in the task bar does not appear:

        @Mask Why don't you use QDialog for your Login instead of QMainWindow? Create QMainWindow only if log-in was successful.

        I've just tried, the result does not change after login does not appear in the taskbar.

        Thanks anyway.

        J Offline
        J Offline
        J.Hilk
        Moderators
        wrote on 15 Oct 2018, 14:54 last edited by
        #6

        @Mask
        my guess would be your homeui has no size defined and defaulted therefor to a size of 0x0


        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


        Q: What's that?
        A: It's blue light.
        Q: What does it do?
        A: It turns blue.

        M 1 Reply Last reply 15 Oct 2018, 16:08
        1
        • J J.Hilk
          15 Oct 2018, 14:54

          @Mask
          my guess would be your homeui has no size defined and defaulted therefor to a size of 0x0

          M Offline
          M Offline
          Mask
          wrote on 15 Oct 2018, 16:08 last edited by
          #7

          @J.Hilk
          The quantities are defined, I also tried to set LoginUI as a window to open after login but nothing has changed.

          An example of my problem:
          0_1539619689118_Desktop Screenshot 2018.10.15 - 18.06.59.55.png

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 15 Oct 2018, 19:14 last edited by
            #8

            Can you show how you start your application and how you use your login widget ?

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            M 1 Reply Last reply 15 Oct 2018, 20:31
            0
            • S SGaist
              15 Oct 2018, 19:14

              Can you show how you start your application and how you use your login widget ?

              M Offline
              M Offline
              Mask
              wrote on 15 Oct 2018, 20:31 last edited by
              #9

              @SGaist
              Of course.

              secdialog.cpp:

              #include "secdialog.h"
              #include "ui_secdialog.h"
              
              #include <QtSql>
              #include <QCryptographicHash>
              #include <QMessageBox>
              #include <QtSql>
              
              SecDialog::SecDialog(QWidget *parent) :
                  QDialog(parent),
                  SecDialogUI(new Ui::SecDialog)
              {
                  SecDialogUI->setupUi(this);
                  SecDialogUI->Login_ErrorLabel->hide();
              
                  setWindowIcon(QIcon(":/Image/mask.png"));
                  LoadDatabase();
              }
              
              SecDialog::~SecDialog()
              {
                  delete SecDialogUI;
              }
              
              void SecDialog::LoadDatabase()
              {
                  QString driver = "QMYSQL";
                  database = QSqlDatabase::addDatabase(driver);
              
                  database.setDatabaseName("clients");
              
                  database.setHostName("localhost");
                  database.setUserName("root");
                  database.setPassword("");
              
                  if (!database.open() )
                  {
                      QMessageBox Error;
                      Error.setText("Problemi di accesso al Database! \nContatta un'amministratore di rete.");
                      Error.exec();
              
                      exit(1);
                  }
              
                  database.close();
              }
              
              void SecDialog::Wait(int Seconds)
              {
                  QTime dieTime= QTime::currentTime().addSecs(Seconds);
                  while (QTime::currentTime() < dieTime)
                      QCoreApplication::processEvents(QEventLoop::AllEvents, 100);
              }
              
              void SecDialog::on_Login_AccessButton_clicked()
              {
                  if(!SecDialogUI->Login_ErrorLabel->isHidden() )
                  {
                      SecDialogUI->Login_ErrorLabel->hide();
                      Wait(1);
                  }
              
                  QString Username = SecDialogUI->Login_UsernameInput->text();
                  QString Password = SecDialogUI->Login_PasswordInput->text();
              
                  if(Username == NULL || Password == NULL)
                      SecDialogUI->Login_ErrorLabel->show();
                  else
                  {
                      database.open();
              
                      QSqlQuery QuerySQL;
                                QuerySQL.prepare("SELECT * FROM users WHERE username = '"+Username+"'");
                                QuerySQL.exec();
              
                       database.close();
              
                       if(QuerySQL.size() < 1)
                           SecDialogUI->Login_ErrorLabel->show();
                       else
                       {
                           QuerySQL.next();
                           UsersInfo.Username = QuerySQL.value("username").toString();
                           UsersInfo.Password = QuerySQL.value("password").toString();
                           UsersInfo.AdminLevel = QuerySQL.value("admin_level").toInt();
                       }
              
                       QString CryptPassword = QCryptographicHash::hash(Password.toLocal8Bit(), QCryptographicHash::Md5).toHex();
              
                       if(UsersInfo.Password == CryptPassword &&  UsersInfo.AdminLevel > 0)
                       {
                           this->close();
              
                           MainWindowUI = new MainWindow(this);
                           MainWindowUI->showMaximized();
                       }
                       else
                           SecDialogUI->Login_ErrorLabel->show();
                  }
              }
              

              Main.cpp:

              #include "secdialog.h"
              
              #include <QApplication>
              #include <QtGui>
              
              int main(int argc, char *argv[])
              {
                  QApplication a(argc, argv);
              
                  SecDialog SecDialogPage;
                  SecDialogPage.setWindowFlags (SecDialogPage.windowFlags () & (~Qt::WindowContextHelpButtonHint) );
              
                  SecDialogPage.show();
              
                  return a.exec();
              }
              

              secdialog.h

              #ifndef SECDIALOG_H
              #define SECDIALOG_H
              
              #include <QDialog>
              #include <QGraphicsScene>
              #include <QtSql>
              
              #include "mainwindow.h"
              
              namespace Ui {
              class SecDialog;
              }
              
              class SecDialog : public QDialog
              {
                  Q_OBJECT
              
              public:
                  explicit SecDialog(QWidget *parent = 0);
                  ~SecDialog();
              
                  void Wait(int Seconds);
                  void LoadDatabase();
              
                  struct Users
                  {
                      QString Username;
                      QString Password;
                      int AdminLevel;
                  } UsersInfo;
              
                  QSqlDatabase database;
              
              private slots:
                  void on_Login_AccessButton_clicked();
              
              private:
                  Ui::SecDialog *SecDialogUI;
                  MainWindow *MainWindowUI;
              };
              
              #endif // SECDIALOG_H
              

              Thanks for the help you are giving me.

              J 1 Reply Last reply 16 Oct 2018, 04:18
              0
              • M Mask
                15 Oct 2018, 20:31

                @SGaist
                Of course.

                secdialog.cpp:

                #include "secdialog.h"
                #include "ui_secdialog.h"
                
                #include <QtSql>
                #include <QCryptographicHash>
                #include <QMessageBox>
                #include <QtSql>
                
                SecDialog::SecDialog(QWidget *parent) :
                    QDialog(parent),
                    SecDialogUI(new Ui::SecDialog)
                {
                    SecDialogUI->setupUi(this);
                    SecDialogUI->Login_ErrorLabel->hide();
                
                    setWindowIcon(QIcon(":/Image/mask.png"));
                    LoadDatabase();
                }
                
                SecDialog::~SecDialog()
                {
                    delete SecDialogUI;
                }
                
                void SecDialog::LoadDatabase()
                {
                    QString driver = "QMYSQL";
                    database = QSqlDatabase::addDatabase(driver);
                
                    database.setDatabaseName("clients");
                
                    database.setHostName("localhost");
                    database.setUserName("root");
                    database.setPassword("");
                
                    if (!database.open() )
                    {
                        QMessageBox Error;
                        Error.setText("Problemi di accesso al Database! \nContatta un'amministratore di rete.");
                        Error.exec();
                
                        exit(1);
                    }
                
                    database.close();
                }
                
                void SecDialog::Wait(int Seconds)
                {
                    QTime dieTime= QTime::currentTime().addSecs(Seconds);
                    while (QTime::currentTime() < dieTime)
                        QCoreApplication::processEvents(QEventLoop::AllEvents, 100);
                }
                
                void SecDialog::on_Login_AccessButton_clicked()
                {
                    if(!SecDialogUI->Login_ErrorLabel->isHidden() )
                    {
                        SecDialogUI->Login_ErrorLabel->hide();
                        Wait(1);
                    }
                
                    QString Username = SecDialogUI->Login_UsernameInput->text();
                    QString Password = SecDialogUI->Login_PasswordInput->text();
                
                    if(Username == NULL || Password == NULL)
                        SecDialogUI->Login_ErrorLabel->show();
                    else
                    {
                        database.open();
                
                        QSqlQuery QuerySQL;
                                  QuerySQL.prepare("SELECT * FROM users WHERE username = '"+Username+"'");
                                  QuerySQL.exec();
                
                         database.close();
                
                         if(QuerySQL.size() < 1)
                             SecDialogUI->Login_ErrorLabel->show();
                         else
                         {
                             QuerySQL.next();
                             UsersInfo.Username = QuerySQL.value("username").toString();
                             UsersInfo.Password = QuerySQL.value("password").toString();
                             UsersInfo.AdminLevel = QuerySQL.value("admin_level").toInt();
                         }
                
                         QString CryptPassword = QCryptographicHash::hash(Password.toLocal8Bit(), QCryptographicHash::Md5).toHex();
                
                         if(UsersInfo.Password == CryptPassword &&  UsersInfo.AdminLevel > 0)
                         {
                             this->close();
                
                             MainWindowUI = new MainWindow(this);
                             MainWindowUI->showMaximized();
                         }
                         else
                             SecDialogUI->Login_ErrorLabel->show();
                    }
                }
                

                Main.cpp:

                #include "secdialog.h"
                
                #include <QApplication>
                #include <QtGui>
                
                int main(int argc, char *argv[])
                {
                    QApplication a(argc, argv);
                
                    SecDialog SecDialogPage;
                    SecDialogPage.setWindowFlags (SecDialogPage.windowFlags () & (~Qt::WindowContextHelpButtonHint) );
                
                    SecDialogPage.show();
                
                    return a.exec();
                }
                

                secdialog.h

                #ifndef SECDIALOG_H
                #define SECDIALOG_H
                
                #include <QDialog>
                #include <QGraphicsScene>
                #include <QtSql>
                
                #include "mainwindow.h"
                
                namespace Ui {
                class SecDialog;
                }
                
                class SecDialog : public QDialog
                {
                    Q_OBJECT
                
                public:
                    explicit SecDialog(QWidget *parent = 0);
                    ~SecDialog();
                
                    void Wait(int Seconds);
                    void LoadDatabase();
                
                    struct Users
                    {
                        QString Username;
                        QString Password;
                        int AdminLevel;
                    } UsersInfo;
                
                    QSqlDatabase database;
                
                private slots:
                    void on_Login_AccessButton_clicked();
                
                private:
                    Ui::SecDialog *SecDialogUI;
                    MainWindow *MainWindowUI;
                };
                
                #endif // SECDIALOG_H
                

                Thanks for the help you are giving me.

                J Offline
                J Offline
                jsulm
                Lifetime Qt Champion
                wrote on 16 Oct 2018, 04:18 last edited by jsulm
                #10

                @Mask You shoud change your design: this dialog should not show the main window (in fact it should not know anything about main window). Do it like this:

                int main(int argc, char *argv[])
                {
                    QApplication a(argc, argv);
                
                    SecDialog *SecDialogPage = new SecDialog();
                    SecDialogPage->setWindowFlags (SecDialogPage.windowFlags () & (~Qt::WindowContextHelpButtonHint) );
                
                    SecDialogPage->exec();
                    if (SecDialogPage->logedOn()) {
                        MainWindowUI = new MainWindow();
                        MainWindowUI->showMaximized();
                    }
                
                    SecDialogPage->deleteLater();
                
                    int ret = a.exec();
                    delete MainWindowUI;
                    return ret;
                }
                

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                J M 2 Replies Last reply 16 Oct 2018, 04:39
                3
                • J jsulm
                  16 Oct 2018, 04:18

                  @Mask You shoud change your design: this dialog should not show the main window (in fact it should not know anything about main window). Do it like this:

                  int main(int argc, char *argv[])
                  {
                      QApplication a(argc, argv);
                  
                      SecDialog *SecDialogPage = new SecDialog();
                      SecDialogPage->setWindowFlags (SecDialogPage.windowFlags () & (~Qt::WindowContextHelpButtonHint) );
                  
                      SecDialogPage->exec();
                      if (SecDialogPage->logedOn()) {
                          MainWindowUI = new MainWindow();
                          MainWindowUI->showMaximized();
                      }
                  
                      SecDialogPage->deleteLater();
                  
                      int ret = a.exec();
                      delete MainWindowUI;
                      return ret;
                  }
                  
                  J Offline
                  J Offline
                  J.Hilk
                  Moderators
                  wrote on 16 Oct 2018, 04:39 last edited by J.Hilk
                  #11

                  @jsulm said in The window in the task bar does not appear:
                  > MainWindowUI = new MainWindow(this);

                  parenting to this shouldn't be possible inside main~~


                  Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                  Q: What's that?
                  A: It's blue light.
                  Q: What does it do?
                  A: It turns blue.

                  J 1 Reply Last reply 16 Oct 2018, 04:40
                  0
                  • J J.Hilk
                    16 Oct 2018, 04:39

                    @jsulm said in The window in the task bar does not appear:
                    > MainWindowUI = new MainWindow(this);

                    parenting to this shouldn't be possible inside main~~

                    J Offline
                    J Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on 16 Oct 2018, 04:40 last edited by
                    #12

                    @J.Hilk Thanks, corrected! Was a copy/paste :-)

                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    1
                    • J jsulm
                      16 Oct 2018, 04:18

                      @Mask You shoud change your design: this dialog should not show the main window (in fact it should not know anything about main window). Do it like this:

                      int main(int argc, char *argv[])
                      {
                          QApplication a(argc, argv);
                      
                          SecDialog *SecDialogPage = new SecDialog();
                          SecDialogPage->setWindowFlags (SecDialogPage.windowFlags () & (~Qt::WindowContextHelpButtonHint) );
                      
                          SecDialogPage->exec();
                          if (SecDialogPage->logedOn()) {
                              MainWindowUI = new MainWindow();
                              MainWindowUI->showMaximized();
                          }
                      
                          SecDialogPage->deleteLater();
                      
                          int ret = a.exec();
                          delete MainWindowUI;
                          return ret;
                      }
                      
                      M Offline
                      M Offline
                      Mask
                      wrote on 16 Oct 2018, 11:02 last edited by Mask
                      #13

                      @jsulm
                      What is "logedOn ()"?

                      J 1 Reply Last reply 17 Oct 2018, 04:12
                      0
                      • M Offline
                        M Offline
                        Mask
                        wrote on 16 Oct 2018, 18:41 last edited by
                        #14

                        I found a solution:

                        int main(int argc, char *argv[])
                        {
                            QApplication a(argc, argv);
                        
                            SecDialog *SecDialogPage = new SecDialog();
                            SecDialogPage->setWindowFlags(Qt::Window);
                        
                            if(SecDialogPage->exec() == QDialog::Accepted)
                            {
                                MainWindow *MainWindowPage = new MainWindow();
                                MainWindowPage->showMaximized();
                            }
                        
                            SecDialogPage->deleteLater();
                        
                            return a.exec();
                        }
                        

                        Thank you all for the help you gave me.

                        1 Reply Last reply
                        0
                        • M Mask
                          16 Oct 2018, 11:02

                          @jsulm
                          What is "logedOn ()"?

                          J Offline
                          J Offline
                          jsulm
                          Lifetime Qt Champion
                          wrote on 17 Oct 2018, 04:12 last edited by
                          #15

                          @Mask said in The window in the task bar does not appear:

                          What is "logedOn ()"?

                          It would be a method in your dialog implemented by you. Returns true when user has successfully logged on, else false.

                          https://forum.qt.io/topic/113070/qt-code-of-conduct

                          M 1 Reply Last reply 17 Oct 2018, 05:48
                          0
                          • J jsulm
                            17 Oct 2018, 04:12

                            @Mask said in The window in the task bar does not appear:

                            What is "logedOn ()"?

                            It would be a method in your dialog implemented by you. Returns true when user has successfully logged on, else false.

                            M Offline
                            M Offline
                            Mask
                            wrote on 17 Oct 2018, 05:48 last edited by
                            #16

                            @jsulm
                            But the "main.cpp" endlessly repeats an if until it's true?
                            Is it okay like I did?

                            J 1 Reply Last reply 17 Oct 2018, 05:57
                            0
                            • M Mask
                              17 Oct 2018, 05:48

                              @jsulm
                              But the "main.cpp" endlessly repeats an if until it's true?
                              Is it okay like I did?

                              J Offline
                              J Offline
                              jsulm
                              Lifetime Qt Champion
                              wrote on 17 Oct 2018, 05:57 last edited by
                              #17

                              @Mask said in The window in the task bar does not appear:

                              But the "main.cpp" endlessly repeats an if until it's true?

                              No, it does not - I don't see any loop there.
                              The code you posted works if you only return QDialog::Accepted in case user was logged on successfully and exiting the app if not.

                              https://forum.qt.io/topic/113070/qt-code-of-conduct

                              M 1 Reply Last reply 17 Oct 2018, 12:41
                              1
                              • J jsulm
                                17 Oct 2018, 05:57

                                @Mask said in The window in the task bar does not appear:

                                But the "main.cpp" endlessly repeats an if until it's true?

                                No, it does not - I don't see any loop there.
                                The code you posted works if you only return QDialog::Accepted in case user was logged on successfully and exiting the app if not.

                                M Offline
                                M Offline
                                Mask
                                wrote on 17 Oct 2018, 12:41 last edited by
                                #18

                                @jsulm
                                I know that no loops are set, but I'm wondering when the main executes that one. Does it only run after the accept () is called?

                                J 1 Reply Last reply 17 Oct 2018, 12:43
                                0
                                • M Mask
                                  17 Oct 2018, 12:41

                                  @jsulm
                                  I know that no loops are set, but I'm wondering when the main executes that one. Does it only run after the accept () is called?

                                  J Offline
                                  J Offline
                                  jsulm
                                  Lifetime Qt Champion
                                  wrote on 17 Oct 2018, 12:43 last edited by
                                  #19

                                  @Mask "SecDialogPage->exec()" returns as soon as user closes dialog either by accepting (OK) or rejecting (Cancel).

                                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                                  M 1 Reply Last reply 18 Oct 2018, 13:53
                                  1
                                  • J jsulm
                                    17 Oct 2018, 12:43

                                    @Mask "SecDialogPage->exec()" returns as soon as user closes dialog either by accepting (OK) or rejecting (Cancel).

                                    M Offline
                                    M Offline
                                    Mask
                                    wrote on 18 Oct 2018, 13:53 last edited by
                                    #20

                                    @jsulm
                                    Ah okay, thank you!

                                    1 Reply Last reply
                                    0
                                    • M Offline
                                      M Offline
                                      Mask
                                      wrote on 19 Oct 2018, 10:27 last edited by Mask
                                      #21

                                      Sorry for yet the disorder, but I can't declare a global variable, should be a variable qsqldatabase, I also tried to create another header files but there are unsuccessful.
                                      How can I do?

                                      J 1 Reply Last reply 19 Oct 2018, 10:33
                                      0
                                      • M Mask
                                        19 Oct 2018, 10:27

                                        Sorry for yet the disorder, but I can't declare a global variable, should be a variable qsqldatabase, I also tried to create another header files but there are unsuccessful.
                                        How can I do?

                                        J Offline
                                        J Offline
                                        jsulm
                                        Lifetime Qt Champion
                                        wrote on 19 Oct 2018, 10:33 last edited by
                                        #22

                                        @Mask You don't need a QSqlDatabase instance and even less so a global variable!
                                        Please take a look at the documentation and example there: http://doc.qt.io/qt-5/qsqldatabase.html

                                        https://forum.qt.io/topic/113070/qt-code-of-conduct

                                        1 Reply Last reply
                                        1

                                        13/22

                                        16 Oct 2018, 11:02

                                        • Login

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