Qt-interest Archive, March 2007
Manipulating the colormap in Qt4 (X11) ?
Message 1 in thread
Hi,
I am doing some research on the colormap capabilities that Qt offers (under Linux/X11). I have been scouring the assistant, lists and the Trolltech website.
In our legacy product (Motif), we need to show alarms flashing in several different places on the screen. The technique that is used is flip the colors in the color map, so that all widgets showing a partiular "color" will be flipped. It is done this way so that all flashing is done at the same time and for performance reasons (changing the colors in individual widgets is a performance hit, and causes a "twinkling" effect).
From what I have found so far, it looks like in order to do the same thing with Qt, the flashable widgets have to be (dervied from) QGLWidget, and QGLColorMap has to be used (and the widgets must have the color map set).
Does anyone on this list know if this is indeed the situation? Is there anything I have missed? Are there references elsewhere that will help me solve this in Qt?
Any feedback is greatly appreciated,
Susan
_____________________________
Susan Macchia
mailto:susan@xxxxxxxxxxxx
http://www.smacchia.net
_____________________________
Message 2 in thread
Hi,
I would like to draw Qt's expand/collapse ([+]/[-]) icon. I tried with the
following code, but it didn't draw anything. I couldn't find anything
useful in the documentation.
Anyone has an idea, why is it not working? And how could I draw these
symbols?
Thanks a lot
Laszlo
void MyWidget::paintEvent(QPaintEvent * /* event */)
{
QPainter painter(this);
QStyleOption option;
option.initFrom(this);
option.rect.setRect(50, 50, 50, 50);
option.state = QStyle::State_Children;
style()->drawPrimitive(QStyle::PE_IndicatorBranch, &option,
&painter, this);
}
_________________________________________________________________________
Shakira legújabb dala, 99 Forintért, kizárólag a T-Online Zeneáruházban!
http://zenearuhaz.t-online.hu/index.php?m=info&albumid=30548&trackid=352953&sp=1&sty=3
--
[ signature omitted ]
Message 3 in thread
Federics László wrote:
> Hi,
>
> I would like to draw Qt's expand/collapse ([+]/[-]) icon. I tried with the
> following code, but it didn't draw anything. I couldn't find anything
> useful in the documentation.
> Anyone has an idea, why is it not working? And how could I draw these
> symbols?
>
> Thanks a lot
> Laszlo
>
> void MyWidget::paintEvent(QPaintEvent * /* event */)
> {
> QPainter painter(this);
>
> QStyleOption option;
> option.initFrom(this);
> option.rect.setRect(50, 50, 50, 50);
> option.state = QStyle::State_Children;
>
> style()->drawPrimitive(QStyle::PE_IndicatorBranch, &option,
> &painter, this);
> }
>
>
You are on the right track, but two possible issues:
1) Use |= to append on to the state variable. = will destroy anything
that is already in there.
2) Use relative coordinates for rect. You are not guaranteed that you
even have QRect(50,50,50,50) in your widget.
Also remember that you have the source code to Qt. If you build it with
debug then you can step right on into the style code and see exactly why
its bailing. Chances are it's something to do with #1 where there is
not enough state information.
--Justin
begin:vcard
begin:vcard
fn:Justin Noel
n:Noel;Justin
org:ICS;Engineering
adr:;;54B Middlesex Trpk;Bedford;MA;01730;USA
email;internet:justin@xxxxxxx
title:Sr. Consulting Engineer / Certified Qt Instructor
tel;work:(617) 621-0060
url:http://www.ics.com
version:2.1
end:vcard
Message 4 in thread
Susan,
There will not be a 1:1 mapping of X color maps to Qt functionality.
However, the same behavior might be accomplished via a different means.
In fact, twiddling with X colormap seems to simply be a "cute" way of
accomplishing this blinking feature on X11. Moving to OpenGL for
something like this seems to be like swatting flies with sledgehammer.
Possibly effective, but tiresome ;)
I haven't tried something like this, but have you tried:
1) Twiddling the global palette on QApplication?
2) Making a singleton relay object that all relevant widgets can connect
to via signals and slots to be notified of this new state and change
their own colors? This would cause a massive number of very short
function calls and a likewise number of repaints (update()). However,
since Qt now has it's own backing store like system there is a small
chance that give a large enough repaint region that the blits might be
large enough and fast enough to look like one update.
I haven't done such a global "blink" before, but maybe another poster
might have a creative Qt solution.
--Justin
Susan Macchia wrote:
> Hi,
>
> I am doing some research on the colormap capabilities that Qt offers
> (under Linux/X11). I have been scouring the assistant, lists and the
> Trolltech website.
>
> In our legacy product (Motif), we need to show alarms flashing in
> several different places on the screen. The technique that is used is
> flip the colors in the color map, so that all widgets showing a
> partiular "color" will be flipped. It is done this way so that all
> flashing is done at the same time and for performance reasons
> (changing the colors in individual widgets is a performance hit, and
> causes a "twinkling" effect).
>
> From what I have found so far, it looks like in order to do the same
> thing with Qt, the flashable widgets have to be (dervied from)
> QGLWidget, and QGLColorMap has to be used (and the widgets must have
> the color map set).
>
> Does anyone on this list know if this is indeed the situation? Is
> there anything I have missed? Are there references elsewhere that
> will help me solve this in Qt?
>
>
> Any feedback is greatly appreciated,
> Susan
> _____________________________
> Susan Macchia
> mailto:susan@xxxxxxxxxxxx
> http://www.smacchia.net
> _____________________________
>
begin:vcard
begin:vcard
fn:Justin Noel
n:Noel;Justin
org:ICS;Engineering
adr:;;54B Middlesex Trpk;Bedford;MA;01730;USA
email;internet:justin@xxxxxxx
title:Sr. Consulting Engineer / Certified Qt Instructor
tel;work:(617) 621-0060
url:http://www.ics.com
version:2.1
end:vcard
Message 5 in thread
Thanks - this is good food for thought. Right now the legacy app uses an external program to change the colormap for this effect. Perhaps that will continue to work since it is not Qt, but is flipping the X colormap? Not very portable, I know, but we don't plan on moving from X.
----- Original Message ----
From: Justin Noel <justin@xxxxxxx>
To: qt-interest@xxxxxxxxxxxxx
Sent: Thursday, March 1, 2007 2:44:52 PM
Subject: Re: Manipulating the colormap in Qt4 (X11) ?
Susan,
There will not be a 1:1 mapping of X color maps to Qt functionality.
However, the same behavior might be accomplished via a different means.
In fact, twiddling with X colormap seems to simply be a "cute" way of
accomplishing this blinking feature on X11. Moving to OpenGL for
something like this seems to be like swatting flies with sledgehammer.
Possibly effective, but tiresome ;)
I haven't tried something like this, but have you tried:
1) Twiddling the global palette on QApplication?
2) Making a singleton relay object that all relevant widgets can connect
to via signals and slots to be notified of this new state and change
their own colors? This would cause a massive number of very short
function calls and a likewise number of repaints (update()). However,
since Qt now has it's own backing store like system there is a small
chance that give a large enough repaint region that the blits might be
large enough and fast enough to look like one update.
I haven't done such a global "blink" before, but maybe another poster
might have a creative Qt solution.
--Justin
Susan Macchia wrote:
> Hi,
>
> I am doing some research on the colormap capabilities that Qt offers
> (under Linux/X11). I have been scouring the assistant, lists and the
> Trolltech website.
>
> In our legacy product (Motif), we need to show alarms flashing in
> several different places on the screen. The technique that is used is
> flip the colors in the color map, so that all widgets showing a
> partiular "color" will be flipped. It is done this way so that all
> flashing is done at the same time and for performance reasons
> (changing the colors in individual widgets is a performance hit, and
> causes a "twinkling" effect).
>
> From what I have found so far, it looks like in order to do the same
> thing with Qt, the flashable widgets have to be (dervied from)
> QGLWidget, and QGLColorMap has to be used (and the widgets must have
> the color map set).
>
> Does anyone on this list know if this is indeed the situation? Is
> there anything I have missed? Are there references elsewhere that
> will help me solve this in Qt?
>
>
> Any feedback is greatly appreciated,
> Susan
> _____________________________
> Susan Macchia
> mailto:susan@xxxxxxxxxxxx
> http://www.smacchia.net
> _____________________________
>
begin:vcard
fn:Justin Noel
n:Noel;Justin
org:ICS;Engineering
adr:;;54B Middlesex Trpk;Bedford;MA;01730;USA
email;internet:justin@xxxxxxx
title:Sr. Consulting Engineer / Certified Qt Instructor
tel;work:(617) 621-0060
url:http://www.ics.com
version:2.1
end:vcard