Problem related to paint event?
-
In my button class i am creating custom button using paint event but in some cases i want normal button. So the problem is that once i
am including paint event function in my button class the normal button disappear. what is the solution to get normal button? -
You could use an if statement in your paintevent. In some cases as you call it, you can then use the ancestor paintevent. In the other cases use your custom behaviour.
-
but in this case also i will not get the normal button provided by qt because writing the paintevent with an empty definition itself making the normal button disappear.
-
So, don't use an empty definition, but use
@
void MyButton::paintEvent(QPaintEvent* pe)
{
if (do_own_drawing) {
//blah, do the drawing
} else {
QPushButton::paintEvent(pe); //assuming your button class inherits QPushButton
}
}
@By the way, did you know that you can also customize the rendering of exiting buttons using style sheets? Not sure what you want to achieve, but that might be easier if you just want to modify the rendering of the button.