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

Qt Code:
  1. public class PrecoMur {
  2.  
  3. QTableWidget table = new QTableWidget(0,7);
  4.  
  5. private QVBoxLayout glayout = new QVBoxLayout();
  6.  
  7. ArrayList data=FenetrePrincipale.mursEdit.getNomsMurs();
  8. ArrayList data1=FenetrePrincipale.mursEdit.getEpaisseursMurs();
  9. ArrayList data2=FenetrePrincipale.mursEdit.getSurfacesMurs();
  10. ArrayList data3=FenetrePrincipale.mursEdit.getReMurs();
  11.  
  12. ArrayList <PrecoMurB> qg=new ArrayList <PrecoMurB> ();
  13.  
  14. //constructeur
  15. public PrecoMur()
  16. {
  17.  
  18. ArrayList<String> labels = new ArrayList<String>();
  19. labels.add("Nom");
  20. labels.add("Surface");
  21. labels.add("Epaisseur");
  22. labels.add("Re");
  23. labels.add("Preco");
  24. labels.add("Modifier");
  25. labels.add("");
  26. table.setHorizontalHeaderLabels(labels);
  27. table.setGridStyle(Qt.PenStyle.NoPen);
  28. table.setAlternatingRowColors(true);
  29. this.qg=addLigne();
  30. glayout.addWidget(table);
  31.  
  32.  
  33. for (int i=0;i<qg.size();i++)
  34. {
  35.  
  36. qg.get(i).p.clicked.connect(this, "preconiser()");
  37. qg.get(i).m.clicked.connect(this,"modifier()");
  38.  
  39. }
  40.  
  41.  
  42.  
  43.  
  44. //insérer le tableau dans la groupbox infospreco
  45. Preconisations.gb.setLayout(glayout);
  46.  
  47. }
  48.  
  49. private ArrayList addLigne() {
  50. // TODO Auto-generated method stub
  51. table.setRowCount(data.size());
  52. ArrayList q= new ArrayList ();
  53. for (int i=0;i<data.size();i++)
  54. {
  55. QPushButton fairepreco=new QPushButton("Préconiser");
  56. QPushButton modifierpreco=new QPushButton("Modifier");
  57.  
  58. c.setEnabled(false);
  59. modifierpreco.setMaximumHeight(20);
  60. modifierpreco.setMinimumHeight(20);
  61. modifierpreco.setMaximumWidth(50);
  62. modifierpreco.setMinimumWidth(50);
  63.  
  64. PrecoMurB b=new PrecoMurB(fairepreco,modifierpreco,c,i);
  65.  
  66. table.setCellWidget(i, 0, new QLabel((String) data.get(i)));
  67. table.setCellWidget(i, 2, new QLabel(data1.get(i)+" cm"));
  68. table.setCellWidget(i, 1, new QLabel(data2.get(i)+" m²"));
  69. table.setCellWidget(i, 3, new QLabel(data3.get(i)+" K.m²/W"));
  70. table.setCellWidget(i, 4, b.p);
  71. table.setCellWidget(i, 5, b.m);
  72. table.setCellWidget(i, 6, b.c);
  73.  
  74.  
  75. q.add(b);
  76. }
  77. table.update();
  78. return q;
  79. }
  80.  
  81.  
  82. public void preconiser()
  83. {
  84. System.out.println("AAAA");
  85. }
To copy to clipboard, switch view to plain text mode