Hello again,
I am trying to make a simple application where when I click a button the count is displayed in the QLineEdit. But I cant get the signal going. I have read different documentations but for custom signal and slots everywhere I see I get a different account or method.
I am posting my files. Please help me understand the concept
click.h
#ifndef CLICK_H
#define CLICK_H
#include<QMainWindow>
#include<QLineEdit>
#include<QPushButton>
namespace Ui
{
class click_me;
}
{
Q_OBJECT
public:
signals:
void click1(int);
private slots:
void disp();
private:
Ui::click_me *ui;
private:
};
#endif
#ifndef CLICK_H
#define CLICK_H
#include<QMainWindow>
#include<QLineEdit>
#include<QPushButton>
namespace Ui
{
class click_me;
}
class click_me:public QMainWindow
{
Q_OBJECT
public:
click_me(QWidget *Parent=0);
signals:
void click1(int);
private slots:
void disp();
private:
Ui::click_me *ui;
private:
QPushButton *p1;
QLineEdit *l1;
};
#endif
To copy to clipboard, switch view to plain text mode
click.cpp
#include"click.h"
#include"ui_click.h"
int count=0;
{
ui->setupUi(this);
//int count=0;
connect(ui->p1,SIGNAL(click1(int)),ui->l1,SLOT(disp(int)));
}
void click_me::disp(int)
{
//emit click1(count);
count = count +1;
ui->l1->setText(s);
}
//int click_me::click1(int co)
//{
//
// emit click1();
//return co;
//}
#include"click.h"
#include"ui_click.h"
int count=0;
click_me::click_me(QWidget *parent):QMainWindow(parent),ui(new Ui::click_me)
{
ui->setupUi(this);
//int count=0;
connect(ui->p1,SIGNAL(click1(int)),ui->l1,SLOT(disp(int)));
}
void click_me::disp(int)
{
//emit click1(count);
count = count +1;
QString s=QString::number(count);
ui->l1->setText(s);
}
//int click_me::click1(int co)
//{
//
// emit click1();
//return co;
//}
To copy to clipboard, switch view to plain text mode
click.zip
I am just unable to understand how do I pass parameters in the signal and even if I am passing one.... How do I go about declaring, defining and passing them.
Clearing its a off day for me :-\
Bookmarks