File indexing completed on 2024-04-28 05:38:40

0001 #include <QtCore/QObject>
0002 #include <QtCore/QVariant>
0003 
0004 void test()
0005 {
0006     QObject o;
0007 
0008     QVariant v, returnedValue;
0009     QMetaObject::invokeMethod(&o, "mySlot",
0010                               Q_RETURN_ARG(QVariant, returnedValue), // OK
0011                               Q_ARG(const QVariant, v)); // Warn
0012     QMetaObject::invokeMethod(&o, "mySlot",
0013                               Q_RETURN_ARG(QVariant, returnedValue), // OK
0014                               Q_ARG(const QVariant, // Warn
0015                                     v)); // multi-line
0016 
0017     Q_ARG(QVariant , v); // OK
0018     Q_ARG(QVariant   &, v); // Warn
0019     Q_ARG(QVariant&, v); // OK
0020     Q_ARG(const QVariant &, v); // Warn
0021 }
0022 
0023 void testConnect()
0024 {
0025     QObject o;
0026     o.connect(&o, SIGNAL(destroyed(int, int)), // Warn
0027               &o, SLOT(void foo(const int))); // Warn
0028     o.connect(&o, SIGNAL(destroyed(int,int)), // OK
0029               &o, SLOT(void foo(int))); // OK
0030 
0031     o.disconnect(&o, SLOT(void foo(const int))); // OK
0032 }
0033 
0034 
0035 class MyObj :public QObject
0036 {
0037 public:
0038     MyObj()
0039     {
0040         connect(ui->host, SIGNAL(textChanged(QString)), // OK
0041                 SLOT(validateHostAddress(const QString&))); // WARN
0042     }
0043 
0044     MyObj *ui;
0045     MyObj *host;
0046 };