I want to make a button to stay pushed after a click. So I made a slot make_pushed which I try to use for that purpose. The button which was clicked on is identified by QObject::sender() method. But something goes wrong since it doesn't work.
QPushButton * size=new QPushButton("size",this);
connect(size, SIGNAL(clicked()), this, SLOT(make_pushed()));
void Window4::make_pushed()
{
QObject* sender = this->sender();
QPushButton* button = qobject_cast<QPushButton*>(sender);
button->setDown(true);
button->setText("Yep");
}
class Window4 : public QWidget
{
public:
Window4(QWidget * parent=0);
private slots:
void make_pushed();
};
There's a mistake in application output "QObject::connect: No such slot QWidget::make_pushed() in" , although everything compiles and the window appears. The problem is the slot is apparently not found, although it is in the same cpp file and in the header. And therefore when clicked, the botton neigher changes its text nor stays pushed.
make_pushed
declared in the header? did you doQ_OBJECTS
? did you doQ_SLOTS
? which QT version? – user3528438