1
//-----------------------------------------------------------------
2
// A demo program showing how to use event filtering
3
//-----------------------------------------------------------------
5
#include <qapplication.h>
6
#include <qmainwindow.h>
7
#include <qwhatsthis.h>
9
#include <qtoolbutton.h>
11
#include "canvaspicker.h"
12
#include "scalepicker.h"
14
int main (int argc, char **argv)
16
QApplication a(argc, argv);
18
QMainWindow mainWindow;
19
QToolBar *toolBar = new QToolBar(&mainWindow);
20
#if QT_VERSION >= 0x040000
21
QAction *action = QWhatsThis::createAction(toolBar);
22
toolBar->addAction(action);
23
mainWindow.addToolBar(toolBar);
25
(void)QWhatsThis::whatsThisButton(toolBar);
28
Plot *plot = new Plot(&mainWindow);
30
// The canvas picker handles all mouse and key
31
// events on the plot canvas
33
(void) new CanvasPicker(plot);
35
// The scale picker translates mouse clicks
36
// int o clicked() signals
38
ScalePicker *scalePicker = new ScalePicker(plot);
39
a.connect(scalePicker, SIGNAL(clicked(int, double)),
40
plot, SLOT(insertCurve(int, double)));
42
mainWindow.setCentralWidget(plot);
43
#if QT_VERSION < 0x040000
44
a.setMainWidget(&mainWindow);
47
mainWindow.resize(540, 400);
51
"An useless plot to demonstrate how to use event filtering.\n\n"
52
"You can click on the color bar, the scales or move the wheel.\n"
53
"All points can be moved using the mouse or the keyboard.";
54
#if QT_VERSION < 0x040000
55
QWhatsThis::add(plot, text);
57
plot->setWhatsThis(text);