Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 4

Qt-interest Archive, June 2007
how to change the appearance of disabled widgets


Message 1 in thread

Hello,

in my program I need the disabled widgets to look like if they where
enabled. For this I create QPallete and overwrite all the "not obsolete
central roles" (http://doc.trolltech.com/4.2/qpalette.html):
QPalette palette;
palette.setColor( QPalette::Disabled, QPalette::Window,
QApplication::palette().color(QPalette::Active, QPalette::Window));
...
this->setPallete(pallete)

For QLineEdits it works fine, i.e. they are disabled and look like the usual
enabled lineedits. But for the other widgets I need (QSlider, QRadioButton,
QCheckBox) this method doesn't work - they look pretty disabled. So I
guess, I'm missing something else. What else do I have to do in order to
get the needed appearance for the disabled widgets?

Thanks in advance.

Alexander Semke.

--
 [ signature omitted ] 

Message 2 in thread

Any particular style that you see this?  I've been able to adjust the 
disabled color using the method you describe for pushbuttons.  The other 
choice you have is to derive your own style and do the painting there.

Alexander Semke wrote:
> Hello,
>
> in my program I need the disabled widgets to look like if they where
> enabled. For this I create QPallete and overwrite all the "not obsolete
> central roles" (http://doc.trolltech.com/4.2/qpalette.html):
> QPalette palette;
> palette.setColor( QPalette::Disabled, QPalette::Window,
> QApplication::palette().color(QPalette::Active, QPalette::Window));
> ...
> this->setPallete(pallete)
>
> For QLineEdits it works fine, i.e. they are disabled and look like the usual
> enabled lineedits. But for the other widgets I need (QSlider, QRadioButton,
> QCheckBox) this method doesn't work - they look pretty disabled. So I
> guess, I'm missing something else. What else do I have to do in order to
> get the needed appearance for the disabled widgets?
>
> Thanks in advance.
>
> Alexander Semke.
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
>
>   



---

This communication contains confidential information. If you are not the intended recipient please return this email to the sender and delete it from your records.

Diese Nachricht enthält vertrauliche Informationen. Sollten Sie nicht der beabsichtigte Empfänger dieser E-mail sein, senden Sie bitte diese an den Absender zurück und löschen Sie die E-mail aus Ihrem System.

--
 [ signature omitted ] 

Message 3 in thread

Susan Macchia wrote:

> Any particular style that you see this?
Yes, it's motif. For plastik setting the color roles does the job.
I'v just tried it for windows-style. Sliders look like enabled, but not the
checkbox and radiobuttons. So it seems to be very style dependent. Thank
you for this hint.

> I've been able to adjust the 
> disabled color using the method you describe for pushbuttons.  The other
> choice you have is to derive your own style and do the painting there.
The software runs on different platforms. In this case I'd need to adjust
this to different styles.

I've also tried to solve my problem by installing an EventFilter and to
throw away all unneeded key*-events and mouse*-events. But somehow I
couldn't manage to write the proper code at the first go (events were
forwarded to the children) and I decided to work with the color roles. May
be I shall look once more at the eventfilter-method...


--
 [ signature omitted ] 

Message 4 in thread


Alexander Semke wrote:
> The software runs on different platforms. In this case I'd need to adjust
> this to different styles.
>   
Yes, you'd have to derive multiple styles to do the same painting for 
each style with issues.  Probably Windows & Motif, since Plastique works.
> I've also tried to solve my problem by installing an EventFilter and to
> throw away all unneeded key*-events and mouse*-events. But somehow I
> couldn't manage to write the proper code at the first go (events were
> forwarded to the children) and I decided to work with the color roles. May
> be I shall look once more at the eventfilter-method...
>   
This would certainly work and might get you by in the short term.  But I 
think the recommended approach is to implement it in the styles.

However having said all of that, it seems to me that this is a bug in 
those styles that don't honor the palette settings.  I'd submit these as 
bugs, or at least ask TT.


---

This communication contains confidential information. If you are not the intended recipient please return this email to the sender and delete it from your records.

Diese Nachricht enthält vertrauliche Informationen. Sollten Sie nicht der beabsichtigte Empfänger dieser E-mail sein, senden Sie bitte diese an den Absender zurück und löschen Sie die E-mail aus Ihrem System.


Message 5 in thread

Alexander Semke wrote:
> I've also tried to solve my problem by installing an EventFilter and to
> throw away all unneeded key*-events and mouse*-events. But somehow I
> couldn't manage to write the proper code at the first go (events were
> forwarded to the children) and I decided to work with the color roles. May
> be I shall look once more at the eventfilter-method...
> 

Also look into the possibility of writing a style proxy 
(http://doc.trolltech.com/qq/qq09-q-and-a.html#style). Create a style 
proxy that just creates a copy of the style option and sets 
State_Enabled. Something like,

MyStyle::drawComplexControl(cc, opt, p, w)
{
case CC_Slider: // for the slider
     if (const QStyleOptionSlider *slider = qstyleoption_cast<const 
QStyleOptionSlider *>(opt)) {
         QStyleOptionSlider sliderCopy(*slider);
         slider.state |= State_Enabled;
         baseStyle->drawComplexControl(cc, &slider, p, w);
     }
}

The big plus with this approach is you do not have to change the palette 
(and also takes care of styles that ignore the palette).

Girish

--
 [ signature omitted ] 

Message 6 in thread

Girish Ramakrishnan wrote:
> Also look into the possibility of writing a style proxy
> (http://doc.trolltech.com/qq/qq09-q-and-a.html#style).
>[...]
Ok, I'll look at this. Thank you.

> The big plus with this approach is you do not have to change the palette
> (and also takes care of styles that ignore the palette).
Well, I need only 10 lines of code or so to change the palettes. If it just
would work... 

Alexander Semke.

--
 [ signature omitted ]