Unsolved QPushButton in a QFrame does not receive clicked signle.
-
I have a QPushButton in a QFrame, and add code below in the mainwindow constructor.
e url)connect(ui->btn_close, &QPushButton::clicked, this, [=]{ qDebug(" button is clicked"); });
But when I clicked button, no clicked single was received. What's the problem? Thanks!
-
I might not be helpful....but aren't you missing the () in your lambda?
connect(ui->btn_close, &QPushButton::clicked, this, [=](){ qDebug(" button is clicked"); });
-
@tannhaus
I addedthis
keyword , the problem is not resovled. -
The following code works:
connect(ui->btn_close, &QPushButton::clicked, this, [=](){qDebug() << "Button is clicked";});
-
@ryman said in QPushButton in a QFrame does not receive clicked signle.:
@tannhaus
I added this keyword , the problem is not resovled.It's not
this
which is at issue. As @tannhaus has shown you, it is parentheses you are missing, please copy & paste his code. -
@JonB said in QPushButton in a QFrame does not receive clicked signle.:
@ryman said in QPushButton in a QFrame does not receive clicked signle.:
@tannhaus
I added this keyword , the problem is not resovled.
It's not
this
which is at issue. As @tannhaus has shown you, it is parentheses you are missing, please copy & paste his code.You might even have to put the bool-parameter (from the clicked-signal) into the parentheses.
connect(ui->btn_close, &QPushButton::clicked, this, [=](bool){ qDebug(" button is clicked"); });
-
@qwasder85
It is good style to do that anyway, but I thought (untested!) that when you have a lambda you can choose to omit parameters if you don't want them.... -
try this:
add this Code in Header File:
private slots: void Click_Event_Of_CloseButton();
add this Code in Source File
connect(ui->btn_close, SIGNAL(clicked()), this, SLOT(Click_Event_Of_CloseButton()));
and write your code in Click_Event_Of_CloseButton function
-
@ryman said in QPushButton in a QFrame does not receive clicked signle.:
But when I clicked button, no clicked single was received. What's the problem? Thanks!
Please provide a minimal, compilable example. I don't see why it should not work.
-
@Ketan__Patel__0011 OP states
btn_close
does not emit the clicked signal at all.