[Qt-interest] Drawing A Disabled QLabel Without Graying It
Nathan Carter
nathancarter5 at gmail.com
Tue Apr 14 03:43:13 CEST 2009
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".
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
More information about the Qt-interest-old
mailing list