[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: problem with creating pixmap that can be toggled by an external event (and more)
From:       Rolf Magnus <ramagnus () zvw ! de>
Date:       2001-11-24 11:18:47
[Download RAW message or body]

On Saturday 24 November 2001 10:00, Ivica Bukvic wrote:

> I've created a separate pthread which deals with accurate timing and
> feeds the main widget class with updated timer values when needed, so
> that when the playback is paused, it triggers the particular class slot
> every second in order to make the led lamp blink. So what happens is
> that since the pixmap has been originally declared as Qlabel pixmap by
> Qt designer, I decided to change its contents by calling
> PlayIndicator->setPixmap( image1 ); (where playindicator is the Qlabel,
> and image1 is an image converted from a file) and have an if statement
> and a control variable that toggles the appearance between two images in
> a timely fashion, so that it appears to be blinking. The problem is that
> when the program is set into motion, the lamp "blinks" ONLY while I move
> the mouse, press stuff on keyboard, or click with the mouse (I do not
> have to click on anything particular, but just have to keep
> moving/clicking anywhere on the desktop). Otherwise the image does not
> change. I've tried update() and repaint(x,y,w,h) methods, but none
> worked.

Qt is not thread save. You shouldn't do gui things (and activating a slot of a 
widget is a gui thing) in more than one thread. Why not simply use a QTimer 
to trigger your signal and maybe a KLed for your led lamp. If you want it to 
be Qt only, that's no problem. KLed can be easily ported to pure Qt.

> The second question refers to a fact that LCD Number widget does not
> support mouse events on it, but I am trying to implement that due to my
> need to create as user-friendly of an interface as possible, so that
> user by clicking onto the lcd number's digit would with LEFT click
> INCREASE value by one, while with RIGHT click decrease by one. Could
> someone please explain me how can I go about achieving this? Do I need
> to put the LCD on top of the hidden button widget or something, and then
> indirectly control the lcd value through secondary mouse-aware widget,
> or is there a more elegant way of solving this problem?

Derive from the LDC widget (it inherits QWidget of course). Then you can 
overwrite mousePressEvent() and mouseReleaseEvent() and whatever else you 
need.

> Finally, is there a way in Qt to differentiate between the left and
> right clicks? If so could you please tell me how?

In mousePressEvent() you get a QMouseEvent that will tell you. See the Qt 
docs.

>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic