Debian Codegraph @

tests/const-signal-or-slot/main.cpp

raw
1 #include <QtCore/QObject>
2
3 class MyObject : public QObject
4 {
5 Q_OBJECT
6 public:
7 bool getter1() const;
8 void nonGetter1() const;
9 bool nonGetter2();
10 public Q_SLOTS:
11 bool slot1() const { return true; } // Warn
12 bool slot2() { return true; } // OK
13
14 bool slot3() const; // Warn
15 bool slot4(); // OK
16 const int slot5(); // OK
17 void slot6() const {} // OK
18 Q_INVOKABLE int invokable1() const; // OK
19 Q_SCRIPTABLE int scriptable1() const; // OK
20 Q_SIGNALS:
21 void signal1() const; // Warn
22 void signal2(); // OK
23 Q_INVOKABLE int invokable2() const; // OK
24 Q_SCRIPTABLE int scriptable2() const; // OK
25 public:
26 Q_INVOKABLE int invokable3() const; // OK
27 Q_SCRIPTABLE int scriptable3() const; // OK
28
29 };
30
31 bool MyObject::slot3() const // OK, already warned
32 {
33 return true;
34 }
35
36 bool MyObject::slot4()
37 {
38 return true;
39 }
40
41 void test()
42 {
43 MyObject o;
44 o.connect(&o, &MyObject::signal1, &MyObject::getter1); // Warn
45 o.connect(&o, &MyObject::signal1, &MyObject::nonGetter1); // OK
46 o.connect(&o, &MyObject::signal1, &MyObject::nonGetter2); // OK
47 }
48
49 void bug386940()
50 {
51 MyObject o;
52 QObject::connect(&o, &MyObject::signal1, []{}); // OK
53 }