[Qt-interest] Drawing A Disabled QLabel Without Graying It
Karol Krizka
kkrizka at gmail.com
Tue Apr 14 03:54:16 CEST 2009
On Mon, Apr 13, 2009 at 6:43 PM, Nathan Carter <nathancarter5 at gmail.com> wrote:
>
> Can you consider using a QStackedWidget? Just put the widget on one
> pane, and put that pane on top when you want the widget "enabled"; put
> the image on the other pane, and put that pane on top when you want
> the widget "disabled".
>
The problem is not switching between the image and the custom widget,
although your suggestion does seem to be clear than what I am doing
right now. Even if I were to replace the parent widget (which wrappers
the custom widget) with a QStackedWidget, to disable the custom widget
I would have to disable the QStackedWidget, since I want the entire
process to be transparent.
--
Cheers,
Karol Krizka
http://www.krizka.net
> Nathan
>
>
> On Apr 13, 2009, at 9:30 PM, Karol Krizka wrote:
>
>> Hi all,
>>
>> I'm wondering if it is possible to disable a QLabel, without it
>> being drawn as
>> grayed out.
>>
>> The reason I'm asking this is because I want to display a static
>> image when
>> one of my custom widgets is disabled. I am currently accomplishing by
>> wrapping the custom widget in a parent QWidget and disabling the
>> custom
>> widget by disabling the parent QWidget. When the QWidget is
>> disabled, it
>> hides the custom widget and instead shows a QLabel with a pixmap. But
>> since the parent QWidget is disabled, the QLabel is disabled too and
>> draw in
>> gray. It does not look too good in gray. So is there an attribute that
>> disables this graying?
>>
>> If not, I thought about two other ways to implement what I described
>> above,
>> so I'm wondering if you have any other suggestions.
>> 1) Override the setEnabled()/isEnabled() methods of the parent
>> QWidget so
>> they only change the status of the custom widget and not the parent
>> QWidget.
>> 2) Override the paintEvent() of the parent QWidget. If the widget is
>> disabled,
>> draw the image. If the widget is enabled, call QWidget::paintEvent()
>> to draw
>> as normally.
>>
>> --
>> Cheers,
>> Karol Krizka
>> http://www.krizka.net
>> _______________________________________________
>> Qt-interest mailing list
>> Qt-interest at trolltech.com
>> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
More information about the Qt-interest-old
mailing list