From 660a7597204104f8bdcbcc43d7697a7b16ed7028 Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Thu, 16 Jan 2003 12:51:02 +0000 Subject: [PATCH] Added QT example. [SVN r16916] --- examples-v2/qt/Jamfile | 2 ++ examples-v2/qt/lcdrange.cpp | 33 ++++++++++++++++++++ examples-v2/qt/lcdrange.qpp | 34 ++++++++++++++++++++ examples-v2/qt/main.cpp | 55 +++++++++++++++++++++++++++++++++ examples-v2/qt/project-root.jam | 10 ++++++ v2/example/qt/Jamfile | 2 ++ v2/example/qt/lcdrange.cpp | 33 ++++++++++++++++++++ v2/example/qt/lcdrange.qpp | 34 ++++++++++++++++++++ v2/example/qt/main.cpp | 55 +++++++++++++++++++++++++++++++++ v2/example/qt/project-root.jam | 10 ++++++ 10 files changed, 268 insertions(+) create mode 100644 examples-v2/qt/Jamfile create mode 100644 examples-v2/qt/lcdrange.cpp create mode 100644 examples-v2/qt/lcdrange.qpp create mode 100644 examples-v2/qt/main.cpp create mode 100644 examples-v2/qt/project-root.jam create mode 100644 v2/example/qt/Jamfile create mode 100644 v2/example/qt/lcdrange.cpp create mode 100644 v2/example/qt/lcdrange.qpp create mode 100644 v2/example/qt/main.cpp create mode 100644 v2/example/qt/project-root.jam diff --git a/examples-v2/qt/Jamfile b/examples-v2/qt/Jamfile new file mode 100644 index 000000000..b7dbc280b --- /dev/null +++ b/examples-v2/qt/Jamfile @@ -0,0 +1,2 @@ + +exe t7 : main.cpp lcdrange.cpp lcdrange.qpp : qt ; \ No newline at end of file diff --git a/examples-v2/qt/lcdrange.cpp b/examples-v2/qt/lcdrange.cpp new file mode 100644 index 000000000..c9a07b81d --- /dev/null +++ b/examples-v2/qt/lcdrange.cpp @@ -0,0 +1,33 @@ +/**************************************************************** +** +** Implementation of LCDRange class, Qt tutorial 7 +** +****************************************************************/ + +#include "lcdrange.qpp" + +#include +#include + +LCDRange::LCDRange( QWidget *parent, const char *name ) + : QVBox( parent, name ) +{ + QLCDNumber *lcd = new QLCDNumber( 2, this, "lcd" ); + slider = new QSlider( Horizontal, this, "slider" ); + slider->setRange( 0, 99 ); + slider->setValue( 0 ); + connect( slider, SIGNAL(valueChanged(int)), + lcd, SLOT(display(int)) ); + connect( slider, SIGNAL(valueChanged(int)), + SIGNAL(valueChanged(int)) ); +} + +int LCDRange::value() const +{ + return slider->value(); +} + +void LCDRange::setValue( int value ) +{ + slider->setValue( value ); +} diff --git a/examples-v2/qt/lcdrange.qpp b/examples-v2/qt/lcdrange.qpp new file mode 100644 index 000000000..0c0219b1b --- /dev/null +++ b/examples-v2/qt/lcdrange.qpp @@ -0,0 +1,34 @@ +/**************************************************************** +** +** Definition of LCDRange class, Qt tutorial 7 +** +****************************************************************/ + +#ifndef LCDRANGE_H +#define LCDRANGE_H + +#include + +class QSlider; + + +class LCDRange : public QVBox +{ + Q_OBJECT +public: + LCDRange( QWidget *parent=0, const char *name=0 ); + + int value() const; + +public slots: + void setValue( int ); + +signals: + void valueChanged( int ); + +private: + QSlider *slider; +}; + + +#endif // LCDRANGE_H diff --git a/examples-v2/qt/main.cpp b/examples-v2/qt/main.cpp new file mode 100644 index 000000000..e2dd6c6f3 --- /dev/null +++ b/examples-v2/qt/main.cpp @@ -0,0 +1,55 @@ +/**************************************************************** +** +** Qt tutorial 7 +** +****************************************************************/ + +#include +#include +#include +#include +#include +#include + +#include "lcdrange.qpp" + + +class MyWidget : public QVBox +{ +public: + MyWidget( QWidget *parent=0, const char *name=0 ); +}; + + +MyWidget::MyWidget( QWidget *parent, const char *name ) + : QVBox( parent, name ) +{ + QPushButton *quit = new QPushButton( "Quit", this, "quit" ); + quit->setFont( QFont( "Times", 18, QFont::Bold ) ); + + connect( quit, SIGNAL(clicked()), qApp, SLOT(quit()) ); + + QGrid *grid = new QGrid( 4, this ); + + LCDRange *previous = 0; + for( int r = 0 ; r < 4 ; r++ ) { + for( int c = 0 ; c < 4 ; c++ ) { + LCDRange* lr = new LCDRange( grid ); + if ( previous ) + connect( lr, SIGNAL(valueChanged(int)), + previous, SLOT(setValue(int)) ); + previous = lr; + } + } +} + + +int main( int argc, char **argv ) +{ + QApplication a( argc, argv ); + + MyWidget w; + a.setMainWidget( &w ); + w.show(); + return a.exec(); +} diff --git a/examples-v2/qt/project-root.jam b/examples-v2/qt/project-root.jam new file mode 100644 index 000000000..82d9c7c1b --- /dev/null +++ b/examples-v2/qt/project-root.jam @@ -0,0 +1,10 @@ + +import gcc ; +import toolset ; + +# Tell that QT should be used. QTDIR will give installation +# prefix. +toolset.using qt ; + +#Alternatively, the prefix can be given as second argument +#toolset.using qt : /usr/share/qt ; \ No newline at end of file diff --git a/v2/example/qt/Jamfile b/v2/example/qt/Jamfile new file mode 100644 index 000000000..b7dbc280b --- /dev/null +++ b/v2/example/qt/Jamfile @@ -0,0 +1,2 @@ + +exe t7 : main.cpp lcdrange.cpp lcdrange.qpp : qt ; \ No newline at end of file diff --git a/v2/example/qt/lcdrange.cpp b/v2/example/qt/lcdrange.cpp new file mode 100644 index 000000000..c9a07b81d --- /dev/null +++ b/v2/example/qt/lcdrange.cpp @@ -0,0 +1,33 @@ +/**************************************************************** +** +** Implementation of LCDRange class, Qt tutorial 7 +** +****************************************************************/ + +#include "lcdrange.qpp" + +#include +#include + +LCDRange::LCDRange( QWidget *parent, const char *name ) + : QVBox( parent, name ) +{ + QLCDNumber *lcd = new QLCDNumber( 2, this, "lcd" ); + slider = new QSlider( Horizontal, this, "slider" ); + slider->setRange( 0, 99 ); + slider->setValue( 0 ); + connect( slider, SIGNAL(valueChanged(int)), + lcd, SLOT(display(int)) ); + connect( slider, SIGNAL(valueChanged(int)), + SIGNAL(valueChanged(int)) ); +} + +int LCDRange::value() const +{ + return slider->value(); +} + +void LCDRange::setValue( int value ) +{ + slider->setValue( value ); +} diff --git a/v2/example/qt/lcdrange.qpp b/v2/example/qt/lcdrange.qpp new file mode 100644 index 000000000..0c0219b1b --- /dev/null +++ b/v2/example/qt/lcdrange.qpp @@ -0,0 +1,34 @@ +/**************************************************************** +** +** Definition of LCDRange class, Qt tutorial 7 +** +****************************************************************/ + +#ifndef LCDRANGE_H +#define LCDRANGE_H + +#include + +class QSlider; + + +class LCDRange : public QVBox +{ + Q_OBJECT +public: + LCDRange( QWidget *parent=0, const char *name=0 ); + + int value() const; + +public slots: + void setValue( int ); + +signals: + void valueChanged( int ); + +private: + QSlider *slider; +}; + + +#endif // LCDRANGE_H diff --git a/v2/example/qt/main.cpp b/v2/example/qt/main.cpp new file mode 100644 index 000000000..e2dd6c6f3 --- /dev/null +++ b/v2/example/qt/main.cpp @@ -0,0 +1,55 @@ +/**************************************************************** +** +** Qt tutorial 7 +** +****************************************************************/ + +#include +#include +#include +#include +#include +#include + +#include "lcdrange.qpp" + + +class MyWidget : public QVBox +{ +public: + MyWidget( QWidget *parent=0, const char *name=0 ); +}; + + +MyWidget::MyWidget( QWidget *parent, const char *name ) + : QVBox( parent, name ) +{ + QPushButton *quit = new QPushButton( "Quit", this, "quit" ); + quit->setFont( QFont( "Times", 18, QFont::Bold ) ); + + connect( quit, SIGNAL(clicked()), qApp, SLOT(quit()) ); + + QGrid *grid = new QGrid( 4, this ); + + LCDRange *previous = 0; + for( int r = 0 ; r < 4 ; r++ ) { + for( int c = 0 ; c < 4 ; c++ ) { + LCDRange* lr = new LCDRange( grid ); + if ( previous ) + connect( lr, SIGNAL(valueChanged(int)), + previous, SLOT(setValue(int)) ); + previous = lr; + } + } +} + + +int main( int argc, char **argv ) +{ + QApplication a( argc, argv ); + + MyWidget w; + a.setMainWidget( &w ); + w.show(); + return a.exec(); +} diff --git a/v2/example/qt/project-root.jam b/v2/example/qt/project-root.jam new file mode 100644 index 000000000..82d9c7c1b --- /dev/null +++ b/v2/example/qt/project-root.jam @@ -0,0 +1,10 @@ + +import gcc ; +import toolset ; + +# Tell that QT should be used. QTDIR will give installation +# prefix. +toolset.using qt ; + +#Alternatively, the prefix can be given as second argument +#toolset.using qt : /usr/share/qt ; \ No newline at end of file