
Problemas con las signals y slot
Publicado por maximiliano (2 intervenciones) el 09/01/2014 04:09:25
Buenas noches, tengo un problema con el tema de las SIGNALS y los SLOT en el Qt creator. Estoy desarrollando el juego Block'D, donde cada ficha es un boton. Mi problema surge de este renglon:
connect(e.boton,SIGNAL(clicked()),this,SLOT(BorrarFichas()));
Yo lo que necesito es meter dos parametros dentro del BorrarFichas(), que serian dos numeros enteros correspondientes a la posicion i,j de mi matriz, para encontrar el boton y realizar las eliminaciones.
Ese connect esta dentro de mi clase Tablero, la cual se define de la siguiente manera en su .h:
#include "ficha.h"
#include<QPushButton>
#include <QtGlobal>
#include <QLabel>
#ifndef TABLERO_H
#define TABLERO_H
class Tablero:public QWidget
{
Q_OBJECT
private:
static const int Filas=10;
static const int Columnas=15;
static const int xFin=1000;
static const int yFin=620;
int Puntaje;
int Nivel;
Ficha matriz[Filas][Columnas];
QLabel*tab;
QLabel*Puntos;
public:
QWidget*principal;///PUBLICO PARA PODER BORRAR UNA FICHA DEL TABLERO
Tablero();
void Inicializar();
void Inicializar_Grafico_Tablero();
void Cerrar();
void Mostrar();
void Set_Puntaje(int puntos);
int Get_Nivel();
int Get_Puntaje();
bool Hay_Movimientos();
Ficha Get_Ficha(int i,int j);
private slots:
void BorrarFichas();
};
#endif // TABLERO_H
Si yo agrego los dos parametros enteros en mi BorrarFicha(), tanto en mi .h como en mi .cpp me tira el siguiente error:
QObject::connect: No such slot Tablero::BorrarFichas(i,j) in ..\Proyecto\tablero.cpp:123
Vi algunos ejemplos, y trate de redefinir el clicked() de la siguiente manera:
Agregue un signal en mi .h:
signal:
void clicked(int, int);
Luego en el cpp de mi tablero, agregue a mi comando clicked los parametros.
connect(e.boton,SIGNAL(clicked(int,int)),this,SLOT(BorrarFichas(I,J)));
emit clicked(I,J);
y el error que me tira es el siguiente:
QObject::connect: No such signal QPushButton::clicked(int,int) in ..\Proyecto\tablero.cpp:123
ESTOY PERDIDO, NECESITO AYUDA, estoy perdiendo tiempo indispensable en este proyecto. Muchas gracias
connect(e.boton,SIGNAL(clicked()),this,SLOT(BorrarFichas()));
Yo lo que necesito es meter dos parametros dentro del BorrarFichas(), que serian dos numeros enteros correspondientes a la posicion i,j de mi matriz, para encontrar el boton y realizar las eliminaciones.
Ese connect esta dentro de mi clase Tablero, la cual se define de la siguiente manera en su .h:
#include "ficha.h"
#include<QPushButton>
#include <QtGlobal>
#include <QLabel>
#ifndef TABLERO_H
#define TABLERO_H
class Tablero:public QWidget
{
Q_OBJECT
private:
static const int Filas=10;
static const int Columnas=15;
static const int xFin=1000;
static const int yFin=620;
int Puntaje;
int Nivel;
Ficha matriz[Filas][Columnas];
QLabel*tab;
QLabel*Puntos;
public:
QWidget*principal;///PUBLICO PARA PODER BORRAR UNA FICHA DEL TABLERO
Tablero();
void Inicializar();
void Inicializar_Grafico_Tablero();
void Cerrar();
void Mostrar();
void Set_Puntaje(int puntos);
int Get_Nivel();
int Get_Puntaje();
bool Hay_Movimientos();
Ficha Get_Ficha(int i,int j);
private slots:
void BorrarFichas();
};
#endif // TABLERO_H
Si yo agrego los dos parametros enteros en mi BorrarFicha(), tanto en mi .h como en mi .cpp me tira el siguiente error:
QObject::connect: No such slot Tablero::BorrarFichas(i,j) in ..\Proyecto\tablero.cpp:123
Vi algunos ejemplos, y trate de redefinir el clicked() de la siguiente manera:
Agregue un signal en mi .h:
signal:
void clicked(int, int);
Luego en el cpp de mi tablero, agregue a mi comando clicked los parametros.
connect(e.boton,SIGNAL(clicked(int,int)),this,SLOT(BorrarFichas(I,J)));
emit clicked(I,J);
y el error que me tira es el siguiente:
QObject::connect: No such signal QPushButton::clicked(int,int) in ..\Proyecto\tablero.cpp:123
ESTOY PERDIDO, NECESITO AYUDA, estoy perdiendo tiempo indispensable en este proyecto. Muchas gracias
Valora esta pregunta


0