summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbustico2011-07-27 14:05:38 +0000
committerbustico2011-07-27 14:05:38 +0000
commita312b9bb47a7ff3bcaf2c771e24382a0a9b279cb (patch)
tree5bd4ea4ebb01b259c257fc9e22c8c5d2129db52a
parent36a248071f5d4145c458dbdfa42e013496385a84 (diff)
downloadivy-cplusplus-a312b9bb47a7ff3bcaf2c771e24382a0a9b279cb.zip
ivy-cplusplus-a312b9bb47a7ff3bcaf2c771e24382a0a9b279cb.tar.gz
ivy-cplusplus-a312b9bb47a7ff3bcaf2c771e24382a0a9b279cb.tar.bz2
ivy-cplusplus-a312b9bb47a7ff3bcaf2c771e24382a0a9b279cb.tar.xz
show how to bind more than one regexp in a Qt inherited class
-rw-r--r--testIvyQt.cxx47
1 files changed, 44 insertions, 3 deletions
diff --git a/testIvyQt.cxx b/testIvyQt.cxx
index 1380982..9eaca76 100644
--- a/testIvyQt.cxx
+++ b/testIvyQt.cxx
@@ -1,7 +1,7 @@
/*
- * Ivy probe
+ * testIvyQt
*
- * Copyright (C) 1997-1999
+ * Copyright (C) 1997-2010
* Centre d'Études de la Navigation Aérienne
*
* Main and only file
@@ -14,6 +14,23 @@
* copyright notice regarding this software
*/
+
+/* this example show how to bind a regexp with a one message / one class methaphor
+ using callback on OnMessage method
+
+ it shows also how to bind several regexp in one class using BindMsg method.
+ it shows a common usage of user_data callback parameter : using it so pass a pointer on object
+
+ usage :
+ launch test_IvyQt
+ in another terminal launch ivyprobe '(.*)'
+ manipulate slider, see effect on ivyprobe
+ send message in ivyprobe : set col red (or any color) and see effects on test_IvyQt
+
+*/
+
+
+
#include <iostream>
#include <fstream>
@@ -72,6 +89,8 @@ class MyWidget : public QWidget, public IvyApplicationCallback, public IvyMessag
void OnApplicationDecongestion(IvyApplication *app);
void OnApplicationFifoFull(IvyApplication *app);
void OnMessage(IvyApplication *app, int argc, const char **argv);
+ static void myOwnCB1 ( IvyApplication *app, void *user_data, int argc, const char **argv );
+ static void myOwnCB2 ( IvyApplication *app, void *user_data, int argc, const char **argv );
private:
QSlider *slider;
@@ -113,14 +132,36 @@ private slots:
}
+void MyWidget::myOwnCB1 ( IvyApplication *app, void *user_data, int argc, const char **argv )
+{
+ printf ("coucou CB1\n");
+}
+void MyWidget::myOwnCB2 ( IvyApplication *app, void *user_data, int argc, const char **argv )
+{
+ MyWidget *w = static_cast<MyWidget *> (user_data);
+ printf ("coucou CB2\n");
+
+ if (argc >= 1) {
+ QPushButton *b = w->quit;
+ QPalette pal = b->palette();
+ QColor color (argv[0]);
+
+ pal.setColor( QPalette::Button, color );
+ b->setPalette( pal );
+ b->setAutoFillBackground( true );
+ } else {
+ printf ("no color given\n");
+ }
+}
void MyWidget::IvyStart()
{
bus = new Ivy( "TestIvyQt", "TestIvyQt READY",
BUS_APPLICATION_CALLBACK( ivyAppConnCb, ivyAppDiscConnCb ),false);
- bus->BindMsg( "(\\d+)", this );
+ bus->BindMsg( "^coucou", new IvyMessageCallbackFunction(myOwnCB1, NULL));
+ bus->BindMsg( "^set col (.*)", new IvyMessageCallbackFunction(myOwnCB2, this));
bus->start(NULL);
}