Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Qt C++ MessageBox

    General and Desktop
    8
    9
    53750
    Loading More Posts
    • 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.
    • W
      wonopon12 last edited by

      Hello, I am just starting off as a GUI Developer for C++. I am experienced with Console Programming. I was looking for a SDK with a simple and organized environment and I found the Qt SDK :) The interfaces are so customizable and I love it! I have one question though. How can I make a MessageBox() appear? Can someone give me an example of a MessageBox() function that works with the Qt SDK. Console & GUI are different.

      The Console version of MessageBox() would work like this :

      @
      MessageBox(NULL, "Hello World!", "Hi!", MB_OK | MB_ICONHAND);
      @

      What would the Qt version of MessageBox() look like? Thanks very much guys :)

      1 Reply Last reply Reply Quote 0
      • V
        vinb last edited by

        http://doc.qt.nokia.com/4.7/qmessagebox.html

        1 Reply Last reply Reply Quote 0
        • D
          durgeshK last edited by

          You can use static member functions of QMessagebox like warning, error, information. Syntax of all of them are same

          StandardButton information ( QWidget * parent, const QString & title, const QString & text, StandardButtons buttons = Ok, StandardButton defaultButton = NoButton )

          And it is being called as follow:

          QMessageBox::information(NULL, "Hello World!", "Hi!");

          You can also use the 'exec()' member function of QMessageBox.

          1 Reply Last reply Reply Quote 0
          • T
            tobias.hunger last edited by

            Please note that QMessageBox is in QtGui, so if you use that you will need to link against that. You also need a QApplication instead of a QCoreApplication.

            I am just mentioning that since you keapt referring to console applications which usually do not need to link against QtGui.

            1 Reply Last reply Reply Quote 0
            • B
              Bittoo last edited by

              Hi PPl
              Here is the sample code for message Box:
              @ QMessageBox msgBox;
              msgBox.setText("The document has been modified.");
              msgBox.setInformativeText("Do you want to save your changes?");
              msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
              msgBox.setDefaultButton(QMessageBox::Save);
              int ret = msgBox.exec();@
              "For More...":http://harmattan-dev.nokia.com/docs/library/html/qt4/qmessagebox.html#Icon-enum

              Regards,
              Manoj Kumar Panwar,

              1 Reply Last reply Reply Quote 0
              • JKSH
                JKSH Moderators last edited by

                Thank you for your contribution, Bittoo. However, check the date -- the question was already answered more than 2 years ago. It's best not to post in old threads. :)

                Also, I recommend using the official Qt Project documentation for most purposes: http://qt-project.org/doc/qt-5.0/qtwidgets/qmessagebox.html -- Nokia's documentation is outdated now.

                Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                1 Reply Last reply Reply Quote 0
                • B
                  Bittoo last edited by

                  Ok JKSH :)

                  Regards,
                  Manoj Kumar Panwar,

                  1 Reply Last reply Reply Quote 0
                  • D
                    Djay96 last edited by

                    thanks

                    1 Reply Last reply Reply Quote 0
                    • H
                      hemal last edited by

                      why was the post not marked as SOLVED then

                      1 Reply Last reply Reply Quote 0
                      • First post
                        Last post