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. How can I use QMessageBox::About differently
Forum Updated to NodeBB v4.3 + New Features

How can I use QMessageBox::About differently

Scheduled Pinned Locked Moved Unsolved General and Desktop
13 Posts 5 Posters 1.2k Views 2 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.
  • Christian EhrlicherC Offline
    Christian EhrlicherC Offline
    Christian Ehrlicher
    Lifetime Qt Champion
    wrote on last edited by
    #2

    @HerrWinfried said in How can I use QMessageBox::About differently:

    but I couldn't.

    What does this mean?

    Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
    Visit the Qt Academy at https://academy.qt.io/catalog

    1 Reply Last reply
    1
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #3

      @HerrWinfried

      Im not sure what you mean by different but for the code shown, don't you miss the part where you show it ?

      Like
      msgBox.exec();

      https://doc.qt.io/qt-5/qmessagebox.html

      HerrWinfriedH 1 Reply Last reply
      0
      • mrjjM mrjj

        @HerrWinfried

        Im not sure what you mean by different but for the code shown, don't you miss the part where you show it ?

        Like
        msgBox.exec();

        https://doc.qt.io/qt-5/qmessagebox.html

        HerrWinfriedH Offline
        HerrWinfriedH Offline
        HerrWinfried
        wrote on last edited by
        #4

        @mrjj @Christian-Ehrlicher

        Let me explain what I want to do, I want to use the code I mentioned above, but in a way that will run QMessageBox::About

        So

        QMessageBox::About(this, "Title", "Message")
        

        I want to revert the code to this, but I don't know how to do it.

          QMessageBox msgBox;
            msgBox.setWindowIcon(QIcon(":/image/52379312.png"));
            msgBox.setIcon(QMessageBox::About);
            msgBox.setWindowTitle(tr("About"));
            msgBox.setText(tr("Text_TEXT");
            QAbstractButton* xokey = msgBox.addButton(tr("Okey"), QMessageBox::YesRole);
        msgBox.exec();
        

        I have no idea how to translate sorry for bad english.

        mrjjM 1 Reply Last reply
        0
        • HerrWinfriedH HerrWinfried

          @mrjj @Christian-Ehrlicher

          Let me explain what I want to do, I want to use the code I mentioned above, but in a way that will run QMessageBox::About

          So

          QMessageBox::About(this, "Title", "Message")
          

          I want to revert the code to this, but I don't know how to do it.

            QMessageBox msgBox;
              msgBox.setWindowIcon(QIcon(":/image/52379312.png"));
              msgBox.setIcon(QMessageBox::About);
              msgBox.setWindowTitle(tr("About"));
              msgBox.setText(tr("Text_TEXT");
              QAbstractButton* xokey = msgBox.addButton(tr("Okey"), QMessageBox::YesRole);
          msgBox.exec();
          

          I have no idea how to translate sorry for bad english.

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #5

          Hi

          You mean like this ?

             QMessageBox msgBox;
              msgBox.setWindowTitle(tr("Title"));
              msgBox.setText(tr("Message"));
              msgBox.setStandardButtons(QMessageBox::StandardButton::Ok);
              msgBox.setIcon(QMessageBox::Information);
          

          alt text

          HerrWinfriedH 1 Reply Last reply
          0
          • mrjjM mrjj

            Hi

            You mean like this ?

               QMessageBox msgBox;
                msgBox.setWindowTitle(tr("Title"));
                msgBox.setText(tr("Message"));
                msgBox.setStandardButtons(QMessageBox::StandardButton::Ok);
                msgBox.setIcon(QMessageBox::Information);
            

            alt text

            HerrWinfriedH Offline
            HerrWinfriedH Offline
            HerrWinfried
            wrote on last edited by
            #6

            @mrjj I wanted the "about(QMessageBox::)" one, but I guess it doesn't seem to exist. I think I will change the icons. thanks anyway

            mrjjM 1 Reply Last reply
            0
            • HerrWinfriedH HerrWinfried

              @mrjj I wanted the "about(QMessageBox::)" one, but I guess it doesn't seem to exist. I think I will change the icons. thanks anyway

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #7

              @HerrWinfried
              Hi
              I think that is what confuses me :) - as on windows the code
              QMessageBox::about(this, "Title", "Message");

              shows

              alt text

              HerrWinfriedH 1 Reply Last reply
              0
              • mrjjM mrjj

                @HerrWinfried
                Hi
                I think that is what confuses me :) - as on windows the code
                QMessageBox::about(this, "Title", "Message");

                shows

                alt text

                HerrWinfriedH Offline
                HerrWinfriedH Offline
                HerrWinfried
                wrote on last edited by HerrWinfried
                #8

                @mrjj said in How can I use QMessageBox::About differently:

                @HerrWinfried
                Hi
                I think that is what confuses me :) - as on windows the code
                QMessageBox::about(this, "Title", "Message");

                shows

                alt text

                It takes whatever icon of the working form file is, otherwise it will be empty.

                6183887b-da3e-4519-b8e5-7ea4b26a32df-image.png

                mrjjM 1 Reply Last reply
                1
                • HerrWinfriedH HerrWinfried

                  @mrjj said in How can I use QMessageBox::About differently:

                  @HerrWinfried
                  Hi
                  I think that is what confuses me :) - as on windows the code
                  QMessageBox::about(this, "Title", "Message");

                  shows

                  alt text

                  It takes whatever icon of the working form file is, otherwise it will be empty.

                  6183887b-da3e-4519-b8e5-7ea4b26a32df-image.png

                  mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by
                  #9

                  @HerrWinfried
                  Ahh. you have this image set as a windows icon ?
                  Or where did you set it before showing the MsgBox ?

                  HerrWinfriedH 1 Reply Last reply
                  0
                  • mrjjM mrjj

                    @HerrWinfried
                    Ahh. you have this image set as a windows icon ?
                    Or where did you set it before showing the MsgBox ?

                    HerrWinfriedH Offline
                    HerrWinfriedH Offline
                    HerrWinfried
                    wrote on last edited by
                    #10

                    @mrjj said in How can I use QMessageBox::About differently:

                    @HerrWinfried
                    Ahh. you have this image set as a windows icon ?
                    Or where did you set it before showing the MsgBox ?

                    Just asking because I don't know, I know as QMessageBox::About

                    mrjjM 1 Reply Last reply
                    0
                    • HerrWinfriedH HerrWinfried

                      @mrjj said in How can I use QMessageBox::About differently:

                      @HerrWinfried
                      Ahh. you have this image set as a windows icon ?
                      Or where did you set it before showing the MsgBox ?

                      Just asking because I don't know, I know as QMessageBox::About

                      mrjjM Offline
                      mrjjM Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on last edited by mrjj
                      #11

                      @HerrWinfried
                      So you did not load this image your self at any point in the app ?

                      It just sort of get its some where ?

                      What platform are you on ?

                      update: ah it does take the Window icon.

                      JonBJ 1 Reply Last reply
                      0
                      • mrjjM mrjj

                        @HerrWinfried
                        So you did not load this image your self at any point in the app ?

                        It just sort of get its some where ?

                        What platform are you on ?

                        update: ah it does take the Window icon.

                        JonBJ Offline
                        JonBJ Offline
                        JonB
                        wrote on last edited by JonB
                        #12

                        @mrjj , @HerrWinfried
                        Not sure what exactly you two are debating. Have you looked at the source of QMessageBox::about()?

                        And it uses QIcon icon = msgBox->windowIcon();

                            \property QWidget::windowIcon
                            \brief the widget's icon
                            This property only makes sense for windows. If no icon
                            has been set, windowIcon() returns the application icon
                            (QApplication::windowIcon()).
                        
                        1 Reply Last reply
                        4
                        • HerrWinfriedH HerrWinfried

                          How can I use it in a different way as I mentioned in the title.
                          I'm planning to do it in the form of the code below, but I couldn't.

                            QMessageBox msgBox;
                              msgBox.setWindowIcon(QIcon(":/image/52379312.png"));
                              msgBox.setIcon(QMessageBox::About);
                              msgBox.setWindowTitle(tr("About"));
                              msgBox.setText(tr("Text_TEXT");
                              QAbstractButton* xokey = msgBox.addButton(tr("Okey"), QMessageBox::YesRole);
                          
                          A Offline
                          A Offline
                          anil_arise
                          wrote on last edited by
                          #13

                          @HerrWinfried Customise QMessageBox with pixmap or icon

                          QMessageBox *infoMSG = new QMessageBox(this);
                          infoMSG->setMaximumSize(400,200);
                          infoMSG->setStyleSheet("background-color: rgb(167, 210, 219); color:rgb(0,0,0);");    
                          infoMSG->setIconPixmap(QPixmap(":/images/Green-true.png").scaled(QSize(30,30)));    
                          infoMSG->setWindowIcon(QIcon(":/images/Admin-logo.png"));
                          infoMSG->setWindowTitle("Title");
                          infoMSG->setText("Message");
                          infoMSG->addButton(QMessageBox::Ok)->setMinimumSize(80,30);
                          infoMSG->buttons().at(0)->setStyleSheet("background-color: rgb(255,153,153);color:rgb(0,0,102);");
                          infoMSG->exec();
                          
                          1 Reply Last reply
                          0

                          • Login

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