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