I'm not sure why I'm having an error saying that SIGNAL was not declared.
mainwindow.cpp:14:78: error: macro "SIGNAL" passed 3 arguments, but takes just 1
mainwindow.
cpp: In constructor ‘MainWindow
::MainWindow(QWidget*)’
:mainwindow.cpp:14:16: error: ‘SIGNAL’ was not declared in this scope
make: *** [mainwindow.o] Error 1
mainwindow.cpp:14:78: error: macro "SIGNAL" passed 3 arguments, but takes just 1
mainwindow.cpp: In constructor ‘MainWindow::MainWindow(QWidget*)’:
mainwindow.cpp:14:16: error: ‘SIGNAL’ was not declared in this scope
make: *** [mainwindow.o] Error 1
To copy to clipboard, switch view to plain text mode
Here is my code
mainwindow.cpp
#include "mainwindow.h"
#include "ui_main.h"
#include "socketthread.h"
#include <QApplication>
using namespace std;
MainWindow
::MainWindow(QWidget *parent
) : ui(new Ui::MainWindow)
{
ui->setupUi(this);
connect(this,
SIGNAL(sendMessage
(QString), SocketThread,
SLOT(send
(QString)));
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_pushButton_clicked()
{
emit sendMessage("ABCD");
}
#include "mainwindow.h"
#include "ui_main.h"
#include "socketthread.h"
#include <QApplication>
using namespace std;
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
connect(this, SIGNAL(sendMessage(QString), SocketThread, SLOT(send(QString)));
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_pushButton_clicked()
{
emit sendMessage("ABCD");
}
To copy to clipboard, switch view to plain text mode
mainwindow.h
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
namespace Ui
{
class MainWindow;
}
Q_OBJECT
public:
~MainWindow();
signals:
private slots:
void on_pushButton_clicked();
private:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
namespace Ui
{
class MainWindow;
}
class MainWindow : public QMainWindow {
Q_OBJECT
public:
MainWindow(QWidget *parent = 0);
~MainWindow();
signals:
void sendMessage(QString message);
private slots:
void on_pushButton_clicked();
private:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H
To copy to clipboard, switch view to plain text mode
socketthread.cpp
void SocketThread::run()
{
.....
.....
string_in = send(); // not sure how to connect the Qstring value here
.....
.....
}
void SocketThread::run()
{
.....
.....
string_in = send(); // not sure how to connect the Qstring value here
.....
.....
}
To copy to clipboard, switch view to plain text mode
socketthread.h
#ifndef SOCKET_H
#define SOCKET_H
#include <QThread>
class SocketThread
: public QThread{
Q_OBJECT
public slots:
private:
void run();
};
#endif // SOCKET_H
#ifndef SOCKET_H
#define SOCKET_H
#include <QThread>
class SocketThread : public QThread
{
Q_OBJECT
public slots:
void send(QString message);
private:
void run();
};
#endif // SOCKET_H
To copy to clipboard, switch view to plain text mode
Bookmarks