2 #include "ace/Get_Opt.h"
3 #include "ace/Argv_Type_Converter.h"
4 #include "tao/QtResource/QtResource_Loader.h"
9 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
11 ACE_Argv_Type_Converter
ct (argc
, argv
);
12 QApplication
app (argc
, ct
.get_ASCII_argv ());
13 TAO::QtResource_Loader
qt_resources (&app
);
18 CORBA::ORB_init (argc
, argv
);
20 Client
client (orb
.in (), app
);
22 client
.parse_args (argc
, argv
);
24 // Creates the Qt widgets
25 client
.create_widgets ();
27 // This may look a bit suspect, but Qt wants the manager widget
28 // as the toplevel widget unlike Xt for display purposes.
29 app
.setActiveWindow (&(client
.mainwindow_
));
31 // Show them on Screen
36 catch (const CORBA::Exception
& ex
)
38 ex
._tao_print_exception ("Caught exception:");
44 Client::Client (CORBA::ORB_ptr orb
,
46 : orb_ (CORBA::ORB::_duplicate (orb
)),
54 delete this->push_button_
;
58 Client::parse_args (int argc
,
61 const ACE_TCHAR
*ior
= ACE_TEXT("file://test.ior");
63 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("k:"));
66 while ((c
= get_opts ()) != -1)
70 ior
= get_opts
.opt_arg ();
81 CORBA::Object_var object
=
82 this->orb_
->string_to_object (ior
);
85 LCD_Display::_narrow (object
.in ());
87 if (CORBA::is_nil(this->server_
.in ()))
90 "\n The server value is nil "));
95 Client::create_widgets (/**/)
98 this->mainwindow_
.resize (200,120);
99 this->mainwindow_
.setWindowTitle("QtClient");
101 // Make a pushbutton widget
102 ACE_NEW (this->push_button_
,
103 QPushButton ("Quit"));
104 box_
.addWidget(this->push_button_
);
106 // Connect the click () SIGNAL routine with the SLOT handler that we
108 QObject::connect (this->push_button_
,
111 SLOT (shutdown_call ()));
113 // Create a slider widget
114 ACE_NEW (this->slider_
,
115 QSlider (Qt::Horizontal
));
117 // Add resource for the slider
118 this->slider_
->setRange (0, 99);
119 this->slider_
->setValue (0);
121 box_
.addWidget(this->slider_
);
124 // Connect the valuechanged SIGNAL routine with the slot that we
125 // have defined. THe slot routine would invoke the remote call.
126 QObject::connect (this->slider_
,
127 SIGNAL (valueChanged (int)),
129 SLOT (remote_call (int)));
131 this->mainwindow_
.setLayout(&box_
);
138 this->mainwindow_
.show ();
142 Client::remote_call (int val
)
144 this->server_
->send_val (val
);
148 Client::shutdown_call ()
150 this->server_
->shutdown ();