source: trunk/examples/i18n/mywidget.cpp

Last change on this file was 2, checked in by dmik, 20 years ago

Imported xplatform parts of the official release 3.3.1 from Trolltech

  • Property svn:keywords set to Id
File size: 2.1 KB
Line 
1/****************************************************************************
2** $Id: mywidget.cpp 2 2005-11-16 15:49:26Z dmik $
3**
4** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
5**
6** This file is part of an example program for Qt. This example
7** program may be used, distributed and modified without limitation.
8**
9*****************************************************************************/
10
11#include <qbuttongroup.h>
12#include <qradiobutton.h>
13#include <qlabel.h>
14#include <qlistbox.h>
15#include <qcombobox.h>
16#include <qlabel.h>
17#include <qhbox.h>
18#include <qvbox.h>
19#include <qaccel.h>
20#include <qpopupmenu.h>
21#include <qmenubar.h>
22#include <qstatusbar.h>
23#include <qapplication.h>
24
25#include "mywidget.h"
26
27MyWidget::MyWidget( QWidget* parent, const char* name )
28 : QMainWindow( parent, name )
29{
30 QVBox* central = new QVBox(this);
31 central->setMargin( 5 );
32 central->setSpacing( 5 );
33 setCentralWidget(central);
34
35 QPopupMenu* file = new QPopupMenu(this);
36 file->insertItem( tr("E&xit"), qApp, SLOT(quit()),
37 QAccel::stringToKey(tr("Ctrl+Q")) );
38 menuBar()->insertItem( tr("&File"), file );
39
40 setCaption( tr( "Internationalization Example" ) );
41
42 QString l;
43 statusBar()->message( tr("Language: English") );
44
45 ( void )new QLabel( tr( "The Main Window" ), central );
46
47 QButtonGroup* gbox = new QButtonGroup( 1, QGroupBox::Horizontal,
48 tr( "View" ), central );
49 (void)new QRadioButton( tr( "Perspective" ), gbox );
50 (void)new QRadioButton( tr( "Isometric" ), gbox );
51 (void)new QRadioButton( tr( "Oblique" ), gbox );
52
53 initChoices(central);
54}
55
56static const char* choices[] = {
57 QT_TRANSLATE_NOOP( "MyWidget", "First" ),
58 QT_TRANSLATE_NOOP( "MyWidget", "Second" ),
59 QT_TRANSLATE_NOOP( "MyWidget", "Third" ),
60 0
61};
62
63void MyWidget::initChoices(QWidget* parent)
64{
65 QListBox* lb = new QListBox( parent );
66 for ( int i = 0; choices[i]; i++ )
67 lb->insertItem( tr( choices[i] ) );
68}
69
70void MyWidget::closeEvent(QCloseEvent* e)
71{
72 QWidget::closeEvent(e);
73 emit closed();
74}
Note: See TracBrowser for help on using the repository browser.