I'm quite new to QT, and I wanted to do the following:
Have a layout which initially consist of 1 QLineEdit (text
) for input and 1 button for confirming it (button
).
Then I wanted to send signal SetN(N)
when the button is clicked and this signal should activate ArrayEdit(N)
slot, which will change the layot to have N inputs (QLineEdit), and 1 button to send what's in them (as one array) to further processing .
I managed to do the first part, but... it didn't work and I don't know how to deal with this no matching member function
error
Here's code of my class:
#include "textlayout.h"
TextLayout::TextLayout()
{
setWindowTitle("Choosing N value");
resize(200, 200);
auto layout = new QGridLayout(this);
auto text = new QLineEdit;
text->resize(10, 30);
auto button = new QPushButton();
button->setText("set");
layout->addWidget(text, 0, 0);
layout->addWidget(button, 0, 1);
QObject::connect(&button, SIGNAL(SetN())„ this, SLOT(ArrayEdit())); //no matching member function for call to 'connect'
int N = text->text().toInt();
if(N > 0)
{
emit SetN(N);
}
}
And its header file:
#ifndef TEXTLAYOUT_H
#define TEXTLAYOUT_H
#include <QWidget>
#include <QLineEdit>
#include <QLabel>
#include <QPushButton>
#include <QGridLayout>
#include <QObject>
class TextLayout : public QWidget
{
Q_OBJECT
public:
TextLayout();
public slots:
void ArrayEdit(int N);I
signals:
void SetN(int N);
};
#endif // TEXTLAYOUT_H
I know that actually now I don't activate this signal on click, but... well previously I didn't realize that and I don't know how to have sent parameter with onclick signal... How can i work around it and how to fix this class?