dear all,
i have some problem when make a connect function which is triggered when a QPushButton was clicked..
the error is
Object::connect: No such slot intervals::writeIntervals(4) in intervals.cpp:21
i give my QPushButton as "Ok", and this is my source code
source for my intervals.h :
#ifndef INTERVALS_H
#define INTERVALS_H
#include <QWidget>
#include <QTextStream>
#include <QFile>
#include <QIODevice>
namespace Ui {
class intervals;
}
Q_OBJECT
public:
~intervals();
void writeInterval(int a);
protected:
private:
Ui::intervals *ui;
public slots:
void writeIntervals(int a);
};
#endif
#ifndef INTERVALS_H
#define INTERVALS_H
#include <QWidget>
#include <QTextStream>
#include <QFile>
#include <QIODevice>
namespace Ui {
class intervals;
}
class intervals : public QWidget {
Q_OBJECT
public:
intervals(QWidget *parent = 0);
~intervals();
QString readInterval();
void writeInterval(int a);
protected:
void changeEvent(QEvent *e);
private:
Ui::intervals *ui;
QString value;
public slots:
void writeIntervals(int a);
};
#endif
To copy to clipboard, switch view to plain text mode
and intervals.cpp
#include "intervals.h"
#include "ui_intervals.h"
intervals
::intervals(QWidget *parent
) : ui(new Ui::intervals)
{
ui->setupUi(this);
QFile file ("interval.txt");
if (!file.exists("interval.txt"))
{
this->writeInterval(5);
ui->IntervalEdit->setText(readInterval());
}
else
{
ui->IntervalEdit->setText(readInterval());
}
qDebug("tes");
connect(ui->Ok,SIGNAL(clicked()),this,SLOT(writeIntervals(4)));
qDebug("tes2");
}
void intervals::writeInterval(int a)
{
QFile file("interval.txt");
{
out << a << "\n";
file.close();
}
}
#include "intervals.h"
#include "ui_intervals.h"
intervals::intervals(QWidget *parent) :
QWidget(parent),
ui(new Ui::intervals)
{
ui->setupUi(this);
QFile file ("interval.txt");
if (!file.exists("interval.txt"))
{
this->writeInterval(5);
ui->IntervalEdit->setText(readInterval());
}
else
{
ui->IntervalEdit->setText(readInterval());
}
qDebug("tes");
connect(ui->Ok,SIGNAL(clicked()),this,SLOT(writeIntervals(4)));
qDebug("tes2");
}
void intervals::writeInterval(int a)
{
QFile file("interval.txt");
if (file.open(QIODevice::WriteOnly | QIODevice::Text))
{
QTextStream out(&file);
out << a << "\n";
file.close();
}
}
To copy to clipboard, switch view to plain text mode
May someone help me with this error?
Bookmarks