Install gettext-0.18.1.1.tar.gz
[msysgit.git] / mingw / share / doc / gettext / examples / hello-c++-kde / hellowindow.cc
blob67aa2b44e6ee0ecb8fbdf4fa0c15b2aec9f4af2f
1 // Example for use of GNU gettext.
2 // Copyright (C) 2003 Free Software Foundation, Inc.
3 // This file is published under the GNU General Public License.
5 #if HAVE_CONFIG_H
6 # include <config.h>
7 #endif
9 /* Specification. */
10 #include "hellowindow.h"
12 /* Declare i18n. */
13 #include <klocale.h>
14 /* Declare KMainWindow. */
15 #include <kmainwindow.h>
16 /* Declare QLabel. */
17 #include <qlabel.h>
18 /* Declare QPushButton. */
19 #include <qpushbutton.h>
20 /* Declare QString. */
21 #include <qstring.h>
22 /* Declare QVBox. */
23 #include <qvbox.h>
24 /* Declare QHBox. */
25 #include <qhbox.h>
27 /* Get getpid() declaration. */
28 #if HAVE_UNISTD_H
29 # include <unistd.h>
30 #endif
32 // The main window widget.
34 HelloMainWindow::HelloMainWindow (QWidget * parent, const char * name)
35 : KMainWindow (parent, name)
37 setCaption ("Hello example");
39 QVBox *panel = new QVBox (this);
40 panel->setSpacing (2);
42 QLabel *label1 = new QLabel (i18n ("Hello, world!"), panel);
44 QString label2text;
45 // NOT using QString::sprintf because it doesn't support reordering of
46 // arguments.
47 //label2text.sprintf (i18n ("This program is running as process number %d"),
48 // getpid ());
49 label2text = i18n ("This program is running as process number %1.").arg(getpid ());
50 QLabel *label2 = new QLabel (label2text, panel);
52 QHBox *buttonbar = new QHBox (panel);
53 QWidget *filler = new QWidget (buttonbar); // makes the button right-aligned
54 button = new QPushButton ("OK", buttonbar);
55 button->setMaximumWidth (button->sizeHint().width() + 20);
57 panel->resize (panel->sizeHint ());
58 resize (panel->frameSize ());
61 HelloMainWindow::~HelloMainWindow ()