Update Qt examples for Qt4.

[SVN r30943]
This commit is contained in:
Vladimir Prus 2005-09-13 11:03:53 +00:00
parent 2a159020c6
commit 44e700b7cb
16 changed files with 299 additions and 9 deletions

12
v2/example/qt/README.txt Normal file
View File

@ -0,0 +1,12 @@
This directory contains Boost.Build examples for the Qt library
(http://www.trolltech.com/products/qt/index.html).
The current examples are:
1. Basic setup -- application with several sources and moccable header.
2. Using of .ui source file.
3. Running .cpp files via the moc tool.
For convenience, there are examples both for 3.* and 4.* version of Qt,
they are mostly identical and differ only in source code.

View File

@ -1,9 +0,0 @@
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 ;

View File

@ -3,6 +3,8 @@
# (See accompanying file LICENSE_1_0.txt
# or copy at http://www.boost.org/LICENSE_1_0.txt)
using qt ;
project
# built MT version, unless asked otherwise.
: default-build <threading>multi

View File

@ -0,0 +1,11 @@
using qt ;
import cast ;
project
: default-build <threading>multi
;
exe main : main.cpp [ cast _ moccable-cpp : main.cpp ]
/qt//qt
;

View File

@ -0,0 +1,41 @@
// Copyright Vladimir Prus 2005.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <qwidget.h>
#include <qpushbutton.h>
#include <qapplication.h>
#include <iostream>
class My_widget : public QWidget
{
Q_OBJECT
public:
My_widget() : QWidget()
{
QPushButton* b = new QPushButton("Push me", this);
connect(b, SIGNAL(clicked()), this, SLOT(theSlot()));
}
private slots:
void theSlot()
{
std::cout << "Clicked\n";
}
};
int main(int ac, char* av[])
{
QApplication app(ac, av);
My_widget mw;
mw.show();
app.setMainWidget(&mw);
app.exec();
}
#include "main.moc"

View File

@ -0,0 +1,15 @@
# Copyright Felix E. Klee, 2003
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt
# or copy at http://www.boost.org/LICENSE_1_0.txt)
# Tell that QT should be used. QTDIR will give installation
# prefix.
using qt ;
project
: default-build <threading>multi
;
exe hello : main.cpp hello_world_widget.ui : <library>/qt//qt ;

View File

@ -0,0 +1,58 @@
<!DOCTYPE UI><UI version="3.0" stdsetdef="1">
<class>HelloWorldWidget</class>
<comment>
<!--
Copyright Felix E. Klee, 2003
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt
or copy at http://www.boost.org/LICENSE_1_0.txt)
-->
</comment>
<widget class="QWidget">
<property name="name">
<cstring>HelloWorldWidget</cstring>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>124</width>
<height>63</height>
</rect>
</property>
<property name="caption">
<string>Hello World!</string>
</property>
<vbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<property name="margin">
<number>11</number>
</property>
<property name="spacing">
<number>6</number>
</property>
<widget class="QLabel">
<property name="name">
<cstring>TextLabel2</cstring>
</property>
<property name="text">
<string>Hello World!</string>
</property>
<property name="alignment">
<set>AlignCenter</set>
</property>
</widget>
<widget class="QPushButton">
<property name="name">
<cstring>OkButton</cstring>
</property>
<property name="text">
<string>OK</string>
</property>
</widget>
</vbox>
</widget>
<layoutdefaults spacing="6" margin="11"/>
</UI>

View File

@ -0,0 +1,18 @@
// Copyright Felix E. Klee, 2003
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
#include "hello_world_widget.h"
#include <qapplication.h>
#include <qpushbutton.h>
int main(int argc, char **argv) {
QApplication a(argc, argv);
HelloWorldWidget w;
QObject::connect(static_cast<QObject*>(w.OkButton), SIGNAL(clicked()), &w, SLOT(close()));
a.setMainWidget(&w);
w.show();
return a.exec();
}

View File

@ -0,0 +1,13 @@
using qt4 : /usr/share/qt4 ;
import cast ;
exe main : main.cpp
[ cast _ moccable-cpp : main.cpp ]
/qt4//QtGui ;
#cast _ moccable-cpp : main.cpp ;

View File

@ -0,0 +1,39 @@
// Copyright Vladimir Prus 2005.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <qwidget.h>
#include <qpushbutton.h>
#include <qapplication.h>
#include <iostream>
class My_widget : public QWidget
{
Q_OBJECT
public:
My_widget() : QWidget()
{
QPushButton* b = new QPushButton("Push me", this);
connect(b, SIGNAL(clicked()), this, SLOT(theSlot()));
}
private slots:
void theSlot()
{
std::cout << "Clicked\n";
}
};
int main(int ac, char* av[])
{
QApplication app(ac, av);
My_widget mw;
mw.show();
app.exec();
}
#include "main.moc"

View File

@ -0,0 +1,12 @@
# Copyright Felix E. Klee, 2003
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt
# or copy at http://www.boost.org/LICENSE_1_0.txt)
using qt4 ;
project
: default-build <threading>multi
;
exe hello : main.cpp hello_world_widget.ui : <library>/qt4//QtGui ;

View File

@ -0,0 +1,55 @@
<ui version="4.0" >
<author></author>
<comment>
<!--
Copyright Felix E. Klee, 2003
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt
or copy at http://www.boost.org/LICENSE_1_0.txt)
-->
</comment>
<exportmacro></exportmacro>
<class>HelloWorldWidget</class>
<widget class="QWidget" name="HelloWorldWidget" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>124</width>
<height>63</height>
</rect>
</property>
<property name="windowTitle" >
<string>Hello World!</string>
</property>
<layout class="QVBoxLayout" >
<property name="margin" >
<number>11</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QLabel" name="TextLabel2" >
<property name="text" >
<string>Hello World!</string>
</property>
<property name="alignment" >
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="OkButton" >
<property name="text" >
<string>OK</string>
</property>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11" />
<pixmapfunction>qPixmapFromMimeSource</pixmapfunction>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,23 @@
// Copyright Felix E. Klee, 2003
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
#include "hello_world_widget.h"
#include <qapplication.h>
#include <qwidget.h>
#include <qpushbutton.h>
int main(int argc, char **argv) {
QApplication a(argc, argv);
QWidget w;
Ui::HelloWorldWidget wm;
wm.setupUi(&w);
QObject::connect(wm.OkButton, SIGNAL(clicked()), &w, SLOT(close()));
w.show();
return a.exec();
}