File: event_filter.cpp

package info (click to toggle)
libqwt 4.2.0-4.1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 9,832 kB
  • ctags: 5,512
  • sloc: cpp: 22,973; ansic: 244; makefile: 66
file content (55 lines) | stat: -rw-r--r-- 1,500 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//-----------------------------------------------------------------
//      A demo program showing how to use event filtering
//-----------------------------------------------------------------

#ifdef QWT_QTOPIA
#include <qpe/qpeapplication.h>
#endif
#include <qapplication.h>
#include <qmainwindow.h>
#include <qwhatsthis.h>
#include <qtoolbar.h>
#include "plot.h"
#include "canvaspicker.h"
#include "scalepicker.h"

int main (int argc, char **argv)
{
#ifdef QWT_QTOPIA
    QPEApplication a(argc, argv);
#else
    QApplication a(argc, argv);
#endif

    QMainWindow mainWindow;
    QToolBar *toolBar = new QToolBar(&mainWindow);
    (void)QWhatsThis::whatsThisButton(toolBar);
    
    Plot *plot = new Plot(&mainWindow);

    // The canvas picker handles all mouse and key
    // events on the plot canvas

    (void) new CanvasPicker(plot);

    // The scale picker translates mouse clicks
    // int o clicked() signals

    ScalePicker *scalePicker = new ScalePicker(plot);
    a.connect(scalePicker, SIGNAL(clicked(int, double)),
        plot, SLOT(insertCurve(int, double)));

    mainWindow.setCentralWidget(plot);
    a.setMainWidget(&mainWindow);

    mainWindow.resize(540, 400);
    mainWindow.show();

    QWhatsThis::add(plot,
        "An useless plot to demonstrate how to use event filtering.\n\n"
        "You can click on the color bar, the scales or move the slider.\n"
        "All points can be moved using the mouse or the keyboard.");

    int rv = a.exec();
    return rv;
}