Hello, I have a problem with the signal slots. I have a main.cpp file and 2 classes, mainwindow and server.
The main.cpp is the next one:
w = new MainWindow();
zerbitzaria = new Server();
//Konexioak egiten dira zerbitzariarekin
qDebug
() <<
QObject::connect(zerbitzaria,
&Server
::setSEtxekoPuntuakGora, w,
&MainWindow
::setMWEtxekoPuntuakGora);
w = new MainWindow();
zerbitzaria = new Server();
//Konexioak egiten dira zerbitzariarekin
qDebug () << QObject::connect(zerbitzaria, &Server::setSEtxekoPuntuakGora, w, &MainWindow::setMWEtxekoPuntuakGora);
To copy to clipboard, switch view to plain text mode
I create 2 different objects and the I connect it.
In the server.h file I have this:
{
Q_OBJECT
signals:
void setSEtxekoPuntuakGora();
class Server: public QObject
{
Q_OBJECT
signals:
void setSEtxekoPuntuakGora();
To copy to clipboard, switch view to plain text mode
In server.cpp I call to the signal using emit command:
switch (comandos)
{
case agindua::EtxekoPuntuakGora:
{
emit setSEtxekoPuntuakGora();
break;
}
}
switch (comandos)
{
case agindua::EtxekoPuntuakGora:
{
emit setSEtxekoPuntuakGora();
break;
}
}
To copy to clipboard, switch view to plain text mode
In the mainwindow class, I have defined the slot(mainwindow.h):
public slots:
void setMWEtxekoPuntuakGora();
public slots:
void setMWEtxekoPuntuakGora();
To copy to clipboard, switch view to plain text mode
And then i have implemented (mainwindows.cpp):
void MainWindow::setMWEtxekoPuntuakGora()
{
int A = ui->LCD_Etxekoak->intValue();
A++;
if (A < 999 && A>=0) ui->LCD_Etxekoak->display(A);
}
void MainWindow::setMWEtxekoPuntuakGora()
{
int A = ui->LCD_Etxekoak->intValue();
A++;
if (A < 999 && A>=0) ui->LCD_Etxekoak->display(A);
}
To copy to clipboard, switch view to plain text mode
both classes has the Q_OBJECT. And I have debugged and see that the connect function return true. Finally I put the breakpoint at the emit setSEtxekoPuntuakGora(); point and I see that the debugger stops there. So everything is ok but it never enters in the slot function.
Can anyone help me?
Thank you
Bookmarks