Selecting QComboBox in QTableWidget

后端 未结 4 1867
梦谈多话
梦谈多话 2021-02-13 02:30

One cell in each row of a QTableWidget contains a combobox

for (each row in table ... ) {
   QComboBox* combo = new QComboBox();      
   table->setCellWidget         


        
4条回答
  •  感动是毒
    2021-02-13 02:41

    No need for the signal mapper... When the combobox is created you can simply add two custom properties to it:

    combo->setProperty("row", (int) nRow);
    combo->setProperty("col", (int) nCol);
    

    In the handler function you can get a pointer back to the sender of the signal (your combobox).

    Now by asking for the properties you can have your row/col back:

    int nRow = sender()->property("row").toInt();
    int nCol = sender()->property("col").toInt();
    

提交回复
热议问题