I want to connect a pushbutton to a client::prework()
. After trivial debugging I find that client::prework()
is not being called (no portion of it is being executed), but the QObject::connect
call returns true
.
client.h
class client : public QObject
{
//some declarations
public slots:
int prework();
};
client.cpp
void client::prework()
{
//implementation
}
mainwindow.cpp
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
QWidget * wdg = new QWidget(this);
QVBoxLayout *vlay = new QVBoxLayout(wdg);
QPushButton *btn1 = new QPushButton("connectme");
vlay->addWidget(btn1);
client obj1;
qDebug()<<"h";
QObject::connect(btn1,SIGNAL(clicked()),&obj1,SLOT(prework()));
// obj1.prework();
}