Namespaces
Variants
Actions
Revision as of 06:49, 20 September 2009 by valderind4 (Talk | contribs)

Archived:How to create interactive messagebox for getting user response in Qt

Jump to: navigation, search
Article Metadata

Tested with
Devices(s): Emulator

Compatibility
Platform(s): S60 3rd Edition, S60 5th Edition

Article
Keywords: QMessageBox
Created: (28 Dec 2008)
Last edited: valderind4 (20 Sep 2009)
{{{width}}}


Contents

Introduction

In this example a messagebox with three buttons is created. User can click on any of these buttons and depending on that a different function can be performed.

Preconditions


Various Function

  • Holds the informative text that provides a fuller description for the message.
msgBox.setInformativeText("Do you want to save your changes?");
  • Holds collection of standard buttons in the message box.
msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
  • Sets the buttons that gets activated when the Escape key is pressed to button.
msgBox.setEscapeButton(QMessageBox::Close);
  • To set The window title
 msgBox.setWindowTitle("HELLO WORLD");

Code

#include <QtGui/QApplication>
#include <QMessageBox>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
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();
app.quit();
return 1;
}


Screen Shot

More about QMessageBox

Msg1.JPG

More about QMessageBox

145 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved