Hello Andre and Mabrouk,
I managed to solve this problem by using QStyleOptionButton, as follows
@if(!icon ().isNull ()){
QStyleOptionButton option;
initStyleOption(&option);
option.text = QString(""); // set the empty string so that only icon is drawn and not the text, when we specify both icon and text.
if(m_mouseOverButton == true){
option.icon = icon().pixmap ( iconSize(), QIcon::Active);
}else{
option.icon = icon().pixmap ( iconSize(), QIcon::Normal);
}
QPainter painter(this);
style()->drawControl(QStyle::CE_PushButton, &option, &painter, this);
//event->ignore ();
}else{
QPushButton::paintEvent (event);
}@
Thus when the icon is present, set the option text to empty string. This way, the original string is preserved.
Thanks a lot for all the help...