showben
2nd March 2011, 14:31
Hello,
I explain my problem and I hope that someone may give me the solution.
Currently I am developing a small application with graphical interfaces and that with Java and Qt
So I create a QTable (a table) and within each line there are QLabels for text and a button that emits a signal.
My table is composed of several lines and therefore more buttons, I want to know what is the button that issued the last signal or in other words which button was clicked.
I searched the web for a few hours but no way because the solution is either in C + + and I can not transcribe it in java or I have not found the solution.
thank you
public class PrecoMur {
QTableWidget table = new QTableWidget(0,7);
private QVBoxLayout glayout = new QVBoxLayout();
ArrayList data=FenetrePrincipale.mursEdit.getNomsMurs();
ArrayList data1=FenetrePrincipale.mursEdit.getEpaisseursMurs ();
ArrayList data2=FenetrePrincipale.mursEdit.getSurfacesMurs() ;
ArrayList data3=FenetrePrincipale.mursEdit.getReMurs();
ArrayList <PrecoMurB> qg=new ArrayList <PrecoMurB> ();
//constructeur
public PrecoMur()
{
ArrayList<String> labels = new ArrayList<String>();
labels.add("Nom");
labels.add("Surface");
labels.add("Epaisseur");
labels.add("Re");
labels.add("Preco");
labels.add("Modifier");
labels.add("");
table.setHorizontalHeaderLabels(labels);
table.setGridStyle(Qt.PenStyle.NoPen);
table.setAlternatingRowColors(true);
this.qg=addLigne();
glayout.addWidget(table);
for (int i=0;i<qg.size();i++)
{
qg.get(i).p.clicked.connect(this, "preconiser()");
qg.get(i).m.clicked.connect(this,"modifier()");
}
//insérer le tableau dans la groupbox infospreco
Preconisations.gb.setLayout(glayout);
}
private ArrayList addLigne() {
// TODO Auto-generated method stub
table.setRowCount(data.size());
ArrayList q= new ArrayList ();
for (int i=0;i<data.size();i++)
{
QPushButton fairepreco=new QPushButton("Préconiser");
QPushButton modifierpreco=new QPushButton("Modifier");
QCheckBox c=new QCheckBox();
c.setEnabled(false);
modifierpreco.setMaximumHeight(20);
modifierpreco.setMinimumHeight(20);
modifierpreco.setMaximumWidth(50);
modifierpreco.setMinimumWidth(50);
PrecoMurB b=new PrecoMurB(fairepreco,modifierpreco,c,i);
table.setCellWidget(i, 0, new QLabel((String) data.get(i)));
table.setCellWidget(i, 2, new QLabel(data1.get(i)+" cm"));
table.setCellWidget(i, 1, new QLabel(data2.get(i)+" m²"));
table.setCellWidget(i, 3, new QLabel(data3.get(i)+" K.m²/W"));
table.setCellWidget(i, 4, b.p);
table.setCellWidget(i, 5, b.m);
table.setCellWidget(i, 6, b.c);
q.add(b);
}
table.update();
return q;
}
public void preconiser()
{
System.out.println("AAAA");
}
I explain my problem and I hope that someone may give me the solution.
Currently I am developing a small application with graphical interfaces and that with Java and Qt
So I create a QTable (a table) and within each line there are QLabels for text and a button that emits a signal.
My table is composed of several lines and therefore more buttons, I want to know what is the button that issued the last signal or in other words which button was clicked.
I searched the web for a few hours but no way because the solution is either in C + + and I can not transcribe it in java or I have not found the solution.
thank you
public class PrecoMur {
QTableWidget table = new QTableWidget(0,7);
private QVBoxLayout glayout = new QVBoxLayout();
ArrayList data=FenetrePrincipale.mursEdit.getNomsMurs();
ArrayList data1=FenetrePrincipale.mursEdit.getEpaisseursMurs ();
ArrayList data2=FenetrePrincipale.mursEdit.getSurfacesMurs() ;
ArrayList data3=FenetrePrincipale.mursEdit.getReMurs();
ArrayList <PrecoMurB> qg=new ArrayList <PrecoMurB> ();
//constructeur
public PrecoMur()
{
ArrayList<String> labels = new ArrayList<String>();
labels.add("Nom");
labels.add("Surface");
labels.add("Epaisseur");
labels.add("Re");
labels.add("Preco");
labels.add("Modifier");
labels.add("");
table.setHorizontalHeaderLabels(labels);
table.setGridStyle(Qt.PenStyle.NoPen);
table.setAlternatingRowColors(true);
this.qg=addLigne();
glayout.addWidget(table);
for (int i=0;i<qg.size();i++)
{
qg.get(i).p.clicked.connect(this, "preconiser()");
qg.get(i).m.clicked.connect(this,"modifier()");
}
//insérer le tableau dans la groupbox infospreco
Preconisations.gb.setLayout(glayout);
}
private ArrayList addLigne() {
// TODO Auto-generated method stub
table.setRowCount(data.size());
ArrayList q= new ArrayList ();
for (int i=0;i<data.size();i++)
{
QPushButton fairepreco=new QPushButton("Préconiser");
QPushButton modifierpreco=new QPushButton("Modifier");
QCheckBox c=new QCheckBox();
c.setEnabled(false);
modifierpreco.setMaximumHeight(20);
modifierpreco.setMinimumHeight(20);
modifierpreco.setMaximumWidth(50);
modifierpreco.setMinimumWidth(50);
PrecoMurB b=new PrecoMurB(fairepreco,modifierpreco,c,i);
table.setCellWidget(i, 0, new QLabel((String) data.get(i)));
table.setCellWidget(i, 2, new QLabel(data1.get(i)+" cm"));
table.setCellWidget(i, 1, new QLabel(data2.get(i)+" m²"));
table.setCellWidget(i, 3, new QLabel(data3.get(i)+" K.m²/W"));
table.setCellWidget(i, 4, b.p);
table.setCellWidget(i, 5, b.m);
table.setCellWidget(i, 6, b.c);
q.add(b);
}
table.update();
return q;
}
public void preconiser()
{
System.out.println("AAAA");
}