lundi 20 avril 2015

UI doesn' t update in qt app

In the code above uitablewidget does not update using signal and slot. It seems as if (ui->tableWidget->setItem(0,0,newItemx);) doesn't work. Am I doing something wrong or is there a better way to update my qtablewidget from my class B?

Class_A::Class_A(QWidget *parent):QDialog(parent),ui(new Ui::Class_A)
{
ui->setupUi(this);

}

Class_A::~Class_A()
{
delete ui;
}


void Class_A::change_TableWidget(double x,double y) // this is the    public slot
{
QTableWidgetItem *newItemx = new QTableWidgetItem(QString::number(x));
ui->tableWidget->setItem(0,0,newItemx);
QTableWidgetItem *newItemy = new QTableWidgetItem(QString::number(y));
ui->tableWidget->setItem(0,0,newItemy);
}




Class_B::Class_B(QWidget *parent) :
 QGLWidget(parent)
{
Class_A *t=new Class_A;
connect(this,SIGNAL(mySignal(double,double)),t,SLOT(change_TableWidget(double,double)));
}


void Class_B::mousePressEvent(QMouseEvent *event)
{
double x = event->x();
double y = event->y();
emit mySignal(x,y);
}

Aucun commentaire:

Enregistrer un commentaire