1 | /****************************************************************
|
---|
2 | **
|
---|
3 | ** Qt tutorial 6
|
---|
4 | **
|
---|
5 | ****************************************************************/
|
---|
6 |
|
---|
7 | #include <qapplication.h>
|
---|
8 | #include <qpushbutton.h>
|
---|
9 | #include <qslider.h>
|
---|
10 | #include <qlcdnumber.h>
|
---|
11 | #include <qfont.h>
|
---|
12 | #include <qvbox.h>
|
---|
13 | #include <qgrid.h>
|
---|
14 |
|
---|
15 | class LCDRange : public QVBox
|
---|
16 | {
|
---|
17 | public:
|
---|
18 | LCDRange( QWidget *parent=0, const char *name=0 );
|
---|
19 | };
|
---|
20 |
|
---|
21 | LCDRange::LCDRange( QWidget *parent, const char *name )
|
---|
22 | : QVBox( parent, name )
|
---|
23 | {
|
---|
24 | QLCDNumber *lcd = new QLCDNumber( 2, this, "lcd" );
|
---|
25 | QSlider * slider = new QSlider( Horizontal, this, "slider" );
|
---|
26 | slider->setRange( 0, 99 );
|
---|
27 | slider->setValue( 0 );
|
---|
28 | connect( slider, SIGNAL(valueChanged(int)), lcd, SLOT(display(int)) );
|
---|
29 | }
|
---|
30 |
|
---|
31 | class MyWidget : public QVBox
|
---|
32 | {
|
---|
33 | public:
|
---|
34 | MyWidget( QWidget *parent=0, const char *name=0 );
|
---|
35 | };
|
---|
36 |
|
---|
37 |
|
---|
38 | MyWidget::MyWidget( QWidget *parent, const char *name )
|
---|
39 | : QVBox( parent, name )
|
---|
40 | {
|
---|
41 | QPushButton *quit = new QPushButton( "Quit", this, "quit" );
|
---|
42 | quit->setFont( QFont( "Times", 18, QFont::Bold ) );
|
---|
43 |
|
---|
44 | connect( quit, SIGNAL(clicked()), qApp, SLOT(quit()) );
|
---|
45 |
|
---|
46 | QGrid *grid = new QGrid( 4, this );
|
---|
47 |
|
---|
48 | for( int r = 0 ; r < 4 ; r++ )
|
---|
49 | for( int c = 0 ; c < 4 ; c++ )
|
---|
50 | (void)new LCDRange( grid );
|
---|
51 | }
|
---|
52 |
|
---|
53 | int main( int argc, char **argv )
|
---|
54 | {
|
---|
55 | QApplication a( argc, argv );
|
---|
56 |
|
---|
57 | MyWidget w;
|
---|
58 | a.setMainWidget( &w );
|
---|
59 | w.show();
|
---|
60 | return a.exec();
|
---|
61 | }
|
---|