Subclassing a QPushButton
I subclassed a QPushButton and in the constructor I changed the text of QPushButton however the text does not change in the actual button any suggestions on why the text is not changing ?
Code:
#ifndef QCUSTOMPUSHBUTTON
#define QCUSTOMPUSHBUTTON
#include "QObject"
#include "QPushButton"
{
Q_OBJECT
public:
{
this->setText("testing123");
}
signals:
void DoubleClick();
protected:
virtual void mouseDoubleClickEvent
(QMouseEvent *) override
{
emit DoubleClick();
}
};
#endif // QCUSTOMPUSHBUTTON
Re: Subclassing a QPushButton
Do you set text anywhere else?
Have you confirmed that you are creating instances of your button?
While that should not make any difference, you can also pass the text to the base class's constructor:
Cheers,
_