[Kde-perl] Delayed show()

Yanick yanick at istop.com
Sun Jul 18 23:18:55 CEST 2004


Hi all,

I'm beginning to play with qtperl, and there some logic of the
event loop that is, well, throwing me off the loop. If anyone
could enlight me on this little puzzle, I'd be very grateful.

In my mainWindow widget, I have a slot that goes like that:

	sub mySlot : SLOT() {
		my $alert = Qt::Widget;
		# build $alert

		$alert->show;
		do_stuff();
	}

The problem is that $alert only shows up once do_stuff() is done. 
I assume (wild speculation from my part) that it's because 
$alert->show throw an event, but doesn't do anything immediatly. 
So I try:


	sub mySlot : SLOT() {
		my $alert = Qt::Widget;
		# build $alert

		$alert->show;
		emit go_do_stuff();  # signal connected to the slot do_stuff();
	}

Still no luck. The only way I've found to do what I want is:

	sub mySlot : SLOT() {
		my $alert = Qt::Widget;
		# build $alert

		$alert->show;
		my $timer = Qt::Timer( this );
		$this->connect( $timer, SIGNAL "timeout()", SLOT "do_stuff()" );
		$time->start( 1, 1 );
	}


But it looks rather clunky. I'm pretty sure there's a 
simplier, more elegant to do that. 


Joy,
`/anick

-- 
True wisdom is less presuming than folly. The wise man doubteth often,
and changeth his mind; the fool is obstinate, and doubteth not; he
knoweth all things but his own ignorance.
- Akhenaton (d. c.1354 BC) Egyptian Pharoah


More information about the Kde-perl mailing list