Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Robrt (1414)

  (email not shown publicly)

robert at perl dot org

Journal of Robrt (1414)

Friday October 04, 2002
09:13 PM

PerlQt, SOAP, and 104 lines of code

[ #8182 ]
I finally got around to playing with PerlQt 3. It's just as cool as I had hoped it would be. (Except of course for the few things that don't work.)

My test case/guinea pig program is a snippet to use's SOAP interface to display journals. (More information on that interface is available here and here.)

It's not perfect. There are some layout issues. If you click on a link on the RHS, you don't get anywhere. I couldn't get PerlQt to change to a Waiting cursor while it was retrieving things. But for a few hours of hacking, it's fun and was a good refresher.

#!/pkg/perl-5.8.0/bin/perl -w

use strict;
use warnings;

# -- Configuration --
my $uid = $ARGV[0] || '1414'; # Robrt my $host = '';
my $uri = "http://$host/Slash/Journal/SOAP";
my $proxy = "http://$host/";
# -- End --

package JournalPanes;
use Qt;
use Qt::isa qw(Qt::Widget);
use Qt::slots
  onQuit => [],
  onRefresh => [],
  onSelect => ['int'],
use Qt::attributes qw(listbox refresh quit textbox journal label data);
use SOAP::Lite;

sub NEW {

  my $layout = Qt::HBoxLayout( this,"hbox" );
  my $leftlayout = Qt::VBoxLayout( $layout,"left" );
  my $rightlayout = Qt::VBoxLayout( $layout,"right" );

  listbox = Qt::ListBox(this);

  refresh = Qt::PushButton("Refresh",this);
  quit = Qt::PushButton("Quit",this);


  my $font = Qt::Font();

  label = Qt::Label(this);

  textbox = Qt::TextBrowser(this);

  this->connect(quit, SIGNAL('clicked()'), SLOT('onQuit()'));
  this->connect(refresh, SIGNAL('clicked()'), SLOT('onRefresh()'));
  this->connect(listbox, SIGNAL('highlighted(int)'), SLOT('onSelect(int)'));

  journal = SOAP::Lite->uri($uri)->proxy($proxy);


sub onQuit {

sub onRefresh {
  # Qt::app->setOverrideCursor( &Qt::WaitCursor );
  data = undef;
  my $entries = journal->get_entries( $uid )->result; # all entries
  my $data = [];
  my $i = 0;
  for (@$entries) {
   $data->[$i++] = [ $_->{subject}, $_->{id} ];
  data = $data;
  # Qt::Application::restoreOverrideCursor();

sub onSelect {
  my ($id) = @_;


  label->setText( data->[$id][0] );

  my $jid = data->[$id][1];
  my $entry = journal->get_entry( $jid )->result;
  my $body = "$entry->{date}<BR>$entry->{url}<BR>$entry->{nickname}<BR><HR>$entry->{body}";

package main;
use Qt;
use JournalPanes;

my $a = Qt::Application(\@ARGV);
my $j = JournalPanes;
$j->resize(470, 300);
$j->setCaption("$host Journals");
exit $a->exec;


The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.