File: d_sigslot.t

package info (click to toggle)
libqt-perl 3.008-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 4,204 kB
  • ctags: 1,367
  • sloc: perl: 16,531; sh: 9,686; cpp: 6,711; makefile: 125
file content (49 lines) | stat: -rw-r--r-- 862 bytes parent folder | download | duplicates (3)
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
BEGIN { print "1..3\n" }

package MyApp;
use Qt;
use Qt::isa qw(Qt::Application);
use Qt::slots
        foo => ['int'],
        baz => [];
use Qt::signals
        bar => ['int'];

sub NEW {
     shift->SUPER::NEW(@_);

     # 1) testing correct subclassing of Qt::Application and this pointer
     print +(ref(this) eq " MyApp")? "ok 1\n" : "not ok\n";
     
     this->connect(this, SIGNAL 'bar(int)', SLOT 'foo(int)');

     # 3) automatic quitting will test Qt sig to custom slot 
     this->connect(this, SIGNAL 'aboutToQuit()', SLOT 'baz()');

     # 2) testing custom sig to custom slot 
     emit bar(3);
}

sub foo
{
    print +($_[0] == 3) ? "ok 2\n" : "not ok\n";
}

sub baz
{
    print "ok 3\n";
}     

1;

package main;

use Qt;
use MyApp;

$a = 0;
$a = MyApp(\@ARGV);

Qt::Timer::singleShot( 300, Qt::app(), SLOT "quit()" );

exit Qt::app()->exec;