QPainter::setClipping(false) is not working(Qt 4.8)
-
Hi,
Do you mean you want to draw on the widget containing the push button from within the button ?
-
Yes. First I checked whether there is a way to disable clipping on widget directly in which case I could have contained a button and label inside a widget. But I dint find a way to do it directly. So I tried subclassing QPushButton and tried to draw text from inside paint event outside the bounds of button with clipping disabled using QPainter methods..
-
Is there a sample to show what you are doing ? Also if you show some image on what you wanted to achieve will also help.
-
@dheerendra
Thanks.I am trying to do like attached image. At a time only one button can be focused and when it gets focused I want to show button's horizontal centre aligned action description below the button. The issue is description can come under another button also and can grow out of buttons bounds.
-
You are slightly over engineering the task. You don't need the painting or subclassing. As @aha_1980 said, it can be managed with simple visual elements like QLabel & Layouts.
-
Out of curiosity, why it there a need for such a description ?
-
@dheerendra
Can you please explain how to do it? Also please note that all the buttons will be dynamic based on some backend response and also spacing between them can change in some scenarios. I tried even this. https://stackoverflow.com/questions/53785115/qpainter-ignores-clipping-inside-paintevent/53785991?noredirect=1#comment94442586_53785991 -
You could have simple QLabel that you would move as need and from which you update the text when the buttons get their focus changed.
-
@SGaist Yes I tried that only. But first time when we switch into the view it doesn't appear properly. Btw button is inside horizontal layout. We kind of wanted to make it reusable since we have that in many places, so I subclassed QPushButton.
-
You can make a "container widget" that will handle the showing of the label properly.