1
votes

So, I'm looking to make a button that becomes flat when pressed in QT5. I've read this
https://woboq.com/blog/new-signals-slots-syntax-in-qt5.html
and it seems that I should be able to do this without making my own button class. So, I've got

QPushButton* button = new QPushButton("text", parent); QObject::connect(button, &QPushButton::clicked, button, &QPushButton::isFlat(true));
and I'm getting
error: call to non-static member function without an object argument
My questions are; am I reading this new syntax wrong? Can I only connect to static functions?

1

1 Answers

3
votes

You are trying to connect a method of no instance, use a lambda for example for capture the button instance:

QObject::connect(button, &QPushButton::clicked, button, 
                 [&button]() {button->setFlat(true)});

Not tested.