Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How create custom Button that inherits from QPushButton



  • Hi,

    I created a custom Button that inherited from QPushButton because I wanted to customized the look and feel.
    So I implemented the PaintEvent(QPaintEvent *e) method, thinking that this method would be called when I create my custome Button in the code, but in debugging I realized that the PainEvent() method never gets called and what gets displayed when the custom Button is created is just a plain QPushButton with the default look and feel skin.
    So I don't understand than how can one overwrite the default PaintEvent() of the QPushButton.

    Does anyone have an example, some code I can look at?

    thank you

    -Malena



  • mayby you have enough with the "stylesheets":http://doc.qt.nokia.com/latest/stylesheet.html?



  • Did you implement PaintEvent() or paintEvent()? The case of the p does matter!



  • Thanks guys for the help. Volker you were right, I was using PaintEvent(), I will try to fix this later. And Vinb , yeah, I ended up using the StyleSheet() in the meantime.

    Best

    -malena



  • Even with style sheets case does matter. It does everywhere in C++.


Log in to reply