mirror of
https://github.com/boostorg/build.git
synced 2026-02-16 13:22:11 +00:00
Added QT example.
[SVN r16916]
This commit is contained in:
2
examples-v2/qt/Jamfile
Normal file
2
examples-v2/qt/Jamfile
Normal file
@@ -0,0 +1,2 @@
|
||||
|
||||
exe t7 : main.cpp lcdrange.cpp lcdrange.qpp : <uses>qt ;
|
||||
33
examples-v2/qt/lcdrange.cpp
Normal file
33
examples-v2/qt/lcdrange.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
/****************************************************************
|
||||
**
|
||||
** Implementation of LCDRange class, Qt tutorial 7
|
||||
**
|
||||
****************************************************************/
|
||||
|
||||
#include "lcdrange.qpp"
|
||||
|
||||
#include <qslider.h>
|
||||
#include <qlcdnumber.h>
|
||||
|
||||
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 );
|
||||
}
|
||||
34
examples-v2/qt/lcdrange.qpp
Normal file
34
examples-v2/qt/lcdrange.qpp
Normal file
@@ -0,0 +1,34 @@
|
||||
/****************************************************************
|
||||
**
|
||||
** Definition of LCDRange class, Qt tutorial 7
|
||||
**
|
||||
****************************************************************/
|
||||
|
||||
#ifndef LCDRANGE_H
|
||||
#define LCDRANGE_H
|
||||
|
||||
#include <qvbox.h>
|
||||
|
||||
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
|
||||
55
examples-v2/qt/main.cpp
Normal file
55
examples-v2/qt/main.cpp
Normal file
@@ -0,0 +1,55 @@
|
||||
/****************************************************************
|
||||
**
|
||||
** Qt tutorial 7
|
||||
**
|
||||
****************************************************************/
|
||||
|
||||
#include <qapplication.h>
|
||||
#include <qpushbutton.h>
|
||||
#include <qlcdnumber.h>
|
||||
#include <qfont.h>
|
||||
#include <qvbox.h>
|
||||
#include <qgrid.h>
|
||||
|
||||
#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();
|
||||
}
|
||||
10
examples-v2/qt/project-root.jam
Normal file
10
examples-v2/qt/project-root.jam
Normal file
@@ -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 ;
|
||||
2
v2/example/qt/Jamfile
Normal file
2
v2/example/qt/Jamfile
Normal file
@@ -0,0 +1,2 @@
|
||||
|
||||
exe t7 : main.cpp lcdrange.cpp lcdrange.qpp : <uses>qt ;
|
||||
33
v2/example/qt/lcdrange.cpp
Normal file
33
v2/example/qt/lcdrange.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
/****************************************************************
|
||||
**
|
||||
** Implementation of LCDRange class, Qt tutorial 7
|
||||
**
|
||||
****************************************************************/
|
||||
|
||||
#include "lcdrange.qpp"
|
||||
|
||||
#include <qslider.h>
|
||||
#include <qlcdnumber.h>
|
||||
|
||||
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 );
|
||||
}
|
||||
34
v2/example/qt/lcdrange.qpp
Normal file
34
v2/example/qt/lcdrange.qpp
Normal file
@@ -0,0 +1,34 @@
|
||||
/****************************************************************
|
||||
**
|
||||
** Definition of LCDRange class, Qt tutorial 7
|
||||
**
|
||||
****************************************************************/
|
||||
|
||||
#ifndef LCDRANGE_H
|
||||
#define LCDRANGE_H
|
||||
|
||||
#include <qvbox.h>
|
||||
|
||||
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
|
||||
55
v2/example/qt/main.cpp
Normal file
55
v2/example/qt/main.cpp
Normal file
@@ -0,0 +1,55 @@
|
||||
/****************************************************************
|
||||
**
|
||||
** Qt tutorial 7
|
||||
**
|
||||
****************************************************************/
|
||||
|
||||
#include <qapplication.h>
|
||||
#include <qpushbutton.h>
|
||||
#include <qlcdnumber.h>
|
||||
#include <qfont.h>
|
||||
#include <qvbox.h>
|
||||
#include <qgrid.h>
|
||||
|
||||
#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();
|
||||
}
|
||||
10
v2/example/qt/project-root.jam
Normal file
10
v2/example/qt/project-root.jam
Normal file
@@ -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 ;
|
||||
Reference in New Issue
Block a user