You are not logged in.

Dear visitor, welcome to KDE-Forum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

markus

Unregistered

1

Monday, June 7th 2004, 7:33pm

QLCDNumber in KDE-Applet

Hello,

I am just writing a small KDE-Applet (created with KDevelop). It creates one class that is inherited from "KPanelApplet" (which is inherited from QWidget). Within the constructor there is a QLCDNumber object created:

w = new QLCDNumber(this);
w->setGeometry( QRect( 0, 0, 100, 46 ) );
w->setNumDigits( 2 );
w->setFrameShape( QLCDNumber::NoFrame );
w->setSegmentStyle( QLCDNumber::Flat );

This works as expected. The number is printed on a transparent background (which updates itself on change).

Now I add one line at the end of the code from above:

w->setPaletteForegroundColor(red);

Now I have a gray box with the numbers (in red) printed on. This gray box shouldnt be there! Have I forgot something important?

Regards
markus

PS:
Debian Sarge
KDE 3.2.2
KDevelop 3.0.3
QT 3.2.3

markus

Unregistered

2

Monday, June 7th 2004, 8:58pm

When I say
setPaletteForegroundColor(red);

it, of course, colors every widget. And the numbers are printed in red and the background is transparent... I dont understand that...

DexterMagnific

Unregistered

3

Tuesday, June 8th 2004, 12:07pm

RE: QLCDNumber in KDE-Applet

I Have exactly the SAME problem ! The widget is transparent until you use setPaletteForegroundColor, then the background becomes non-transparent.

Sorry for my English.

markus

Unregistered

4

Saturday, June 12th 2004, 8:24pm

When I insert my applet, logoff and logon again, the color is black. When I insert it manually it is red! Whats that?!?

DexterMagnific

Unregistered

5

Monday, June 14th 2004, 10:13am

RE: QLCDNumber in KDE-Applet

I think it's a bug.
if you want to make a widget transparent (partially or not), you have to define yourself the regions that have to be transparent. You can do such by calling setMask, which takes a QBitmap :

First, you set the use of a mask :

setUseMask(true);

Then, you create a QBitmap that has exaclty the size of your widget, and you fill the regions that are to be transparent with the value color0

At last, you apply the mask

setMask(myBitmap).

Here is an example that displays a pixmap on a transparent background :

----------------------------------------------------------
TransparentPixmap::TransparentPixmap(const QPixmap &image, QWidget *parent, const char *name, WFlags f)
: QWidget(parent, name, f)
{
setAutoMask(true);
resize(image.size());
setPaletteBackgroundPixmap(image);

QBitmap bm(image.createHeuristicMask());
setMask(bm);
}

TransparentPixmap::~TransparentPixmap()
{
}
--------------------------------------------------

image.createHeuristicMask() returns a mask which is suitable for pixmaps (in particulary, it has exactly the size of the pixmap). If the pixmap supports transparency (for example a .png pixmap), then it returns a mask where transperent pixels of the pixmap are replaced by color0 (a special color that means transparent) in the QBitmap.

Sometimes, this doesn't work.

Good Luck.