Qt-interest Archive, May 2007
Slot not geting executed
Message 1 in thread
Hi,
I am not able to connect clicked signal with a slot in a dialog.
In the code below, the slot is never executed.
Would someone explain me what I am doing wrong ?
Thnx
Prateek
//header
class __declspec(dllexport) Dialog : public QDialog
{
Q_OBJECT
QWidget *m_parent;
QLabel *label;
QLineEdit *lineEdit;
QPushButton *OkButton;
public:
Dialog(QWidget *parent = 0);
public slots:
void OnOk();
};
//.cpp
#include <QHBoxLayout>
Dialog::Dialog(QWidget *parent) : QDialog(parent)
{
m_parent = parent;
label = new QLabel("Enter the note here");
lineEdit = new QLineEdit;
label->setBuddy(lineEdit);
OkButton = new QPushButton("OK");
QHBoxLayout *layout = new QHBoxLayout;
layout->addWidget(label);
layout->addWidget(lineEdit);
layout->addWidget(OkButton);
setLayout(layout);
bool val = connect(OkButton, SIGNAL(clicked()), this, SLOT(OnOK())); //
the val is always false
}
void Dialog::OnOk() // This is never executed
{
QString str = lineEdit->text();
MyView *top = (MyView*)m_parent;
TextNote *note = top->getActiveTextNote();
note->setPlainText(str);
}
Message 2 in thread
While checking the return value of the connect is a good start, look at
the debug stream... You will see that there is no slot OnOK()
The reason is, your dialogs method is OnOk() note the case.
Scott
________________________________
From: Prateek Tiwari [mailto:ptiwari@xxxxxxxxxxx]
Sent: Tuesday, May 01, 2007 11:51 PM
To: qt-interest@xxxxxxxxxxxxx
Subject: Slot not geting executed
Hi,
I am not able to connect clicked signal with a slot in a dialog.
In the code below, the slot is never executed.
Would someone explain me what I am doing wrong ?
Thnx
Prateek
//header
class __declspec(dllexport) Dialog : public QDialog
{
Q_OBJECT
QWidget *m_parent;
QLabel *label;
QLineEdit *lineEdit;
QPushButton *OkButton;
public:
Dialog(QWidget *parent = 0);
public slots:
void OnOk();
};
//.cpp
#include <QHBoxLayout>
Dialog::Dialog(QWidget *parent) : QDialog(parent)
{
m_parent = parent;
label = new QLabel("Enter the note here");
lineEdit = new QLineEdit;
label->setBuddy(lineEdit);
OkButton = new QPushButton("OK");
QHBoxLayout *layout = new QHBoxLayout;
layout->addWidget(label);
layout->addWidget(lineEdit);
layout->addWidget(OkButton);
setLayout(layout);
bool val = connect(OkButton, SIGNAL(clicked()), this, SLOT(OnOK())); //
the val is always false
}
void Dialog::OnOk() // This is never executed
{
QString str = lineEdit->text();
MyView *top = (MyView*)m_parent;
TextNote *note = top->getActiveTextNote();
note->setPlainText(str);
}
Message 3 in thread
Oops! Thnx and sorry for the trivial mail.
________________________________
From: Scott Aron Bloom [mailto:scott@xxxxxxxxxxxx]
Sent: Wednesday, May 02, 2007 12:48 PM
To: Prateek Tiwari; qt-interest@xxxxxxxxxxxxx
Subject: RE: Slot not geting executed
While checking the return value of the connect is a good start,
look at the debug stream... You will see that there is no slot OnOK()
The reason is, your dialogs method is OnOk() note the case.
Scott
________________________________
From: Prateek Tiwari [mailto:ptiwari@xxxxxxxxxxx]
Sent: Tuesday, May 01, 2007 11:51 PM
To: qt-interest@xxxxxxxxxxxxx
Subject: Slot not geting executed
Hi,
I am not able to connect clicked signal with a slot in a dialog.
In the code below, the slot is never executed.
Would someone explain me what I am doing wrong ?
Thnx
Prateek
//header
class __declspec(dllexport) Dialog : public QDialog
{
Q_OBJECT
QWidget *m_parent;
QLabel *label;
QLineEdit *lineEdit;
QPushButton *OkButton;
public:
Dialog(QWidget *parent = 0);
public slots:
void OnOk();
};
//.cpp
#include <QHBoxLayout>
Dialog::Dialog(QWidget *parent) : QDialog(parent)
{
m_parent = parent;
label = new QLabel("Enter the note here");
lineEdit = new QLineEdit;
label->setBuddy(lineEdit);
OkButton = new QPushButton("OK");
QHBoxLayout *layout = new QHBoxLayout;
layout->addWidget(label);
layout->addWidget(lineEdit);
layout->addWidget(OkButton);
setLayout(layout);
bool val = connect(OkButton, SIGNAL(clicked()), this,
SLOT(OnOK())); // the val is always false
}
void Dialog::OnOk() // This is never executed
{
QString str = lineEdit->text();
MyView *top = (MyView*)m_parent;
TextNote *note = top->getActiveTextNote();
note->setPlainText(str);
}