source: trunk/tutorial/t8/main.cpp@ 137

Last change on this file since 137 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: 1.6 KB
Line 
1/****************************************************************
2**
3** Qt tutorial 8
4**
5****************************************************************/
6
7#include <qapplication.h>
8#include <qpushbutton.h>
9#include <qlcdnumber.h>
10#include <qfont.h>
11#include <qlayout.h>
12
13#include "lcdrange.h"
14#include "cannon.h"
15
16
17class MyWidget: public QWidget
18{
19public:
20 MyWidget( QWidget *parent=0, const char *name=0 );
21};
22
23
24MyWidget::MyWidget( QWidget *parent, const char *name )
25 : QWidget( parent, name )
26{
27 QPushButton *quit = new QPushButton( "Quit", this, "quit" );
28 quit->setFont( QFont( "Times", 18, QFont::Bold ) );
29
30 connect( quit, SIGNAL(clicked()), qApp, SLOT(quit()) );
31
32 LCDRange *angle = new LCDRange( this, "angle" );
33 angle->setRange( 5, 70 );
34
35 CannonField *cannonField
36 = new CannonField( this, "cannonField" );
37
38 connect( angle, SIGNAL(valueChanged(int)),
39 cannonField, SLOT(setAngle(int)) );
40 connect( cannonField, SIGNAL(angleChanged(int)),
41 angle, SLOT(setValue(int)) );
42
43 QGridLayout *grid = new QGridLayout( this, 2, 2, 10 );
44 //2x2, 10 pixel border
45
46 grid->addWidget( quit, 0, 0 );
47 grid->addWidget( angle, 1, 0, Qt::AlignTop );
48 grid->addWidget( cannonField, 1, 1 );
49 grid->setColStretch( 1, 10 );
50
51 angle->setValue( 60 );
52 angle->setFocus();
53}
54
55
56int main( int argc, char **argv )
57{
58 QApplication a( argc, argv );
59
60 MyWidget w;
61 w.setGeometry( 100, 100, 500, 355 );
62 a.setMainWidget( &w );
63 w.show();
64 return a.exec();
65}
Note: See TracBrowser for help on using the repository browser.